improve handling of context lengths

This commit is contained in:
rhiannon morris 2023-10-15 16:23:38 +02:00
parent 2e9183bc14
commit 0c1df54d62
12 changed files with 64 additions and 47 deletions

View file

@ -86,18 +86,16 @@ export covering
whnf0 : {0 isRedex : RedexTest tm} -> CanWhnf tm isRedex =>
ErasureContext d n -> SQty ->
tm d n -> Eff Erase (tm d n)
whnf0 ctx sg tm = do
let Val n = ctx.termLen; Val d = ctx.dimLen
liftWhnf $ whnf0 !(askAt DEFS) (toWhnfContext ctx) sg tm
whnf0 ctx sg tm = liftWhnf $ whnf0 !(askAt DEFS) (toWhnfContext ctx) sg tm
export covering
computeElimType : ErasureContext d n -> SQty -> Elim d n -> Eff Erase (Term d n)
computeElimType ctx sg e = do
let Val n = ctx.termLen; Val d = ctx.dimLen
ctx = toWhnfContext ctx
defs <- askAt DEFS
Element e enf <- liftWhnf $ whnf defs ctx sg e
liftWhnf $ computeElimType defs ctx sg e
defs <- askAt DEFS
liftWhnf $ do
let ctx = toWhnfContext ctx
Element e enf <- whnf defs ctx sg e
computeElimType defs ctx sg e
parameters (ctx : ErasureContext d n) (loc : Loc)
@ -279,9 +277,7 @@ eraseElim ctx e@(F x u loc) = do
| Nothing => throw $ NotInScope x
case isErased def.qty.qty of
Erased => throw $ CompileTimeOnly ctx $ E e
Kept =>
let Val d = ctx.dimLen; Val n = ctx.termLen in
pure $ EraRes def.type $ F x loc
Kept => pure $ EraRes (def.typeWith ctx.dimLen ctx.termLen) $ F x loc
-- π ≠ 0
-- ----------------------------