add FromVarR, etc
`FromVarR` is a version of `FromVar` which needs the scope size to be relevant at runtime
This commit is contained in:
parent
85f20680e6
commit
c063107ecc
5 changed files with 199 additions and 69 deletions
|
@ -60,9 +60,31 @@ namespace DSubst.DScopeTermN
|
|||
S ns (N body) // th = S ns $ N $ body // th
|
||||
|
||||
|
||||
export %inline FromVar (Elim d) where fromVar = B
|
||||
export %inline FromVar (Term d) where fromVar = E .: fromVar
|
||||
export %inline
|
||||
FromVarR (Elim d) where fromVarR = B
|
||||
|
||||
export %inline
|
||||
FromVar (Elim d) where fromVar = B; fromVarSame _ _ = Refl
|
||||
|
||||
export %inline
|
||||
FromVarR (Term d) where fromVarR = E .: fromVarR
|
||||
|
||||
export %inline
|
||||
FromVar (Term d) where fromVar = E .: fromVar; fromVarSame _ _ = Refl
|
||||
|
||||
|
||||
export
|
||||
CanSubstSelf (Elim d)
|
||||
|
||||
private
|
||||
tsubstElim : Elim d from -> Lazy (TSubst d from to) -> Elim d to
|
||||
tsubstElim (F x u loc) _ = F x u loc
|
||||
tsubstElim (B i loc) th = get th i loc
|
||||
tsubstElim (CloE (Sub e ph)) th = assert_total CloE $ Sub e $ ph . th
|
||||
tsubstElim e th =
|
||||
case force th of
|
||||
Shift SZ => e
|
||||
th => CloE $ Sub e th
|
||||
|
||||
||| does the minimal reasonable work:
|
||||
||| - deletes the closure around a *free* name
|
||||
|
@ -70,14 +92,10 @@ export %inline FromVar (Term d) where fromVar = E .: fromVar
|
|||
||| - composes (lazily) with an existing top-level closure
|
||||
||| - immediately looks up a bound variable
|
||||
||| - otherwise, wraps in a new closure
|
||||
CanSubstSelfR (Elim d) where (//?) = tsubstElim
|
||||
|
||||
export
|
||||
CanSubstSelf (Elim d) where
|
||||
F x u loc // _ = F x u loc
|
||||
B i loc // th = get th i loc
|
||||
CloE (Sub e ph) // th = assert_total CloE $ Sub e $ ph . th
|
||||
e // th = case force th of
|
||||
Shift SZ => e
|
||||
th => CloE $ Sub e th
|
||||
CanSubstSelf (Elim d) where (//) = tsubstElim; substSame _ _ = Refl
|
||||
|
||||
namespace CanTSubst
|
||||
public export
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue