rewrite Context.(!!)
This commit is contained in:
parent
88338050fc
commit
3efff3e96d
1 changed files with 17 additions and 8 deletions
|
@ -66,19 +66,28 @@ tel1 . (tel2 :< s) = (tel1 . tel2) :< s
|
||||||
|
|
||||||
|
|
||||||
public export
|
public export
|
||||||
getShift : CanShift tm => Context tm len -> Var len -> Shift len out -> tm out
|
getShiftWith : (forall from, to. tm from -> Shift from to -> tm to) ->
|
||||||
getShift (ctx :< t) VZ by = t // drop1 by
|
Shift len out -> Context tm len -> Var len -> tm out
|
||||||
getShift (ctx :< t) (VS i) by = getShift ctx i (drop1 by)
|
getShiftWith shft by (ctx :< t) VZ = t `shft` drop1 by
|
||||||
|
getShiftWith shft by (ctx :< t) (VS i) = getShiftWith shft (drop1 by) ctx i
|
||||||
|
|
||||||
|
public export %inline
|
||||||
|
getShift : CanShift tm => Shift len out -> Context tm len -> Var len -> tm out
|
||||||
|
getShift = getShiftWith (//)
|
||||||
|
|
||||||
|
public export %inline
|
||||||
|
getWith : (forall from, to. tm from -> Shift from to -> tm to) ->
|
||||||
|
Context tm len -> Var len -> tm len
|
||||||
|
getWith shft = getShiftWith shft SZ
|
||||||
|
|
||||||
infixl 8 !!
|
infixl 8 !!
|
||||||
public export %inline
|
|
||||||
(!!) : CanShift tm => Context tm len -> Var len -> tm len
|
(!!) : CanShift tm => Context tm len -> Var len -> tm len
|
||||||
ctx !! i = getShift ctx i SZ
|
(!!) = getWith (//)
|
||||||
|
|
||||||
infixl 8 !?
|
infixl 8 !!!
|
||||||
public export %inline
|
public export %inline
|
||||||
(!?) : Context' tm len -> Var len -> tm
|
(!!!) : Context' tm len -> Var len -> tm
|
||||||
ctx !? i = (ctx !! i) @{Const}
|
(!!!) = getWith const
|
||||||
|
|
||||||
|
|
||||||
||| a triangle of bindings. each type binding in a context counts the ues of
|
||| a triangle of bindings. each type binding in a context counts the ues of
|
||||||
|
|
Loading…
Reference in a new issue