feat: add liftLevelM
This commit is contained in:
parent
9d577fb2d9
commit
387dbd4036
2 changed files with 13 additions and 0 deletions
|
|
@ -81,5 +81,8 @@ partial def elabLevel : Syntax → LevelElabM Level
|
|||
throwError stx "unexpected universe level syntax kind"
|
||||
|
||||
end Level
|
||||
|
||||
export Level (LevelElabM)
|
||||
|
||||
end Elab
|
||||
end Lean
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import Init.Lean.Hygiene
|
|||
import Init.Lean.Elab.Log
|
||||
import Init.Lean.Elab.Alias
|
||||
import Init.Lean.Elab.ResolveName
|
||||
import Init.Lean.Elab.Level
|
||||
|
||||
namespace Lean
|
||||
namespace Elab
|
||||
|
|
@ -262,6 +263,15 @@ match u? with
|
|||
| some u => pure u
|
||||
| none => throwError ref ("invalid universe level, " ++ u ++ " is not greater than 0")
|
||||
|
||||
def liftLevelM {α} (x : LevelElabM α) : TermElabM α :=
|
||||
fun ctx s =>
|
||||
match (x { .. ctx }).run { .. s } with
|
||||
| EStateM.Result.ok a newS => EStateM.Result.ok a { mctx := newS.mctx, ngen := newS.ngen, .. s }
|
||||
| EStateM.Result.error ex newS => EStateM.Result.error (Exception.error ex) s
|
||||
|
||||
def elabLevel (stx : Syntax) : TermElabM Level :=
|
||||
liftLevelM $ Level.elabLevel stx
|
||||
|
||||
/- Elaborate `x` with `stx` on the macro stack -/
|
||||
@[inline] def withMacroExpansion {α} (stx : Syntax) (x : TermElabM α) : TermElabM α :=
|
||||
adaptReader (fun (ctx : Context) => { macroStack := stx :: ctx.macroStack, .. ctx }) x
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue