mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-25 22:06:33 +03:00
Add missing source file
(I did add this, then I messed around with git and apparently broke it without noticing. Oops!)
This commit is contained in:
parent
65b3ddb81b
commit
2f20f7e136
40
src/TTImp/Elab/Utils.idr
Normal file
40
src/TTImp/Elab/Utils.idr
Normal file
@ -0,0 +1,40 @@
|
||||
module TTImp.Elab.Utils
|
||||
|
||||
import Core.Context
|
||||
import Core.Core
|
||||
import Core.Env
|
||||
import Core.Normalise
|
||||
import Core.TT
|
||||
import Core.Value
|
||||
|
||||
import TTImp.TTImp
|
||||
|
||||
findErasedFrom : Defs -> Nat -> NF [] -> Core (List Nat)
|
||||
findErasedFrom defs pos (NBind fc x (Pi c _ _) scf)
|
||||
= do sc <- scf defs (toClosure defaultOpts [] (Erased fc))
|
||||
rest <- findErasedFrom defs (1 + pos) sc
|
||||
case c of
|
||||
Rig0 => pure (pos :: rest)
|
||||
_ => pure rest
|
||||
findErasedFrom defs pos tm = pure []
|
||||
|
||||
-- Find the argument positions in the given type which are guaranteed to be
|
||||
-- erasable
|
||||
export
|
||||
findErased : {auto c : Ref Ctxt Defs} ->
|
||||
ClosedTerm -> Core (List Nat)
|
||||
findErased tm
|
||||
= do defs <- get Ctxt
|
||||
tmnf <- nf defs [] tm
|
||||
findErasedFrom defs 0 tmnf
|
||||
|
||||
export
|
||||
updateErasable : {auto c : Ref Ctxt Defs} ->
|
||||
Name -> Core ()
|
||||
updateErasable n
|
||||
= do defs <- get Ctxt
|
||||
Just gdef <- lookupCtxtExact n (gamma defs)
|
||||
| Nothing => pure ()
|
||||
es <- findErased (type gdef)
|
||||
addDef n (record { eraseArgs = es } gdef)
|
||||
pure ()
|
Loading…
Reference in New Issue
Block a user