feat: add tryOpt
This commit is contained in:
parent
00b991baf6
commit
2867cd627b
1 changed files with 16 additions and 0 deletions
|
|
@ -163,6 +163,22 @@ do s ← get;
|
|||
(do restore env mctx postponed; pure false))
|
||||
(fun ex => do restore env mctx postponed; throw ex)
|
||||
|
||||
@[specialize] def tryOpt {α} (x : MetaM (Option α)) : MetaM (Option α) :=
|
||||
do s ← get;
|
||||
let env := s.env;
|
||||
let mctx := s.mctx;
|
||||
let postponed := s.postponed;
|
||||
modify $ fun s => { postponed := {}, .. s };
|
||||
catch
|
||||
(do a? ← x;
|
||||
match a? with
|
||||
| some a =>
|
||||
condM processPostponed
|
||||
(pure (some a))
|
||||
(do restore env mctx postponed; pure none)
|
||||
| none => do restore env mctx postponed; pure none)
|
||||
(fun ex => do restore env mctx postponed; throw ex)
|
||||
|
||||
/- Public interface -/
|
||||
|
||||
def isLevelDefEq (u v : Level) : MetaM Bool :=
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue