Skip to content

Commit

Permalink
feat: return QuotedDefEq from Meta wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed Jan 14, 2025
1 parent f0c584b commit cc24b34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Qq/Match.lean
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ scoped elab "_qq_match" pat:term " ← " e:term " | " alt:term " in " body:term
let argLvlExpr ← mkFreshExprMVarQ q(Level)
let argTyExpr ← mkFreshExprMVarQ q(Quoted (.sort $argLvlExpr))
let e' ← elabTermEnsuringTypeQ e q(Quoted $argTyExpr)
let argTyExpr ← instantiateMVarsQ argTyExpr
let argTyExpr, _⟩ ← instantiateMVarsQ argTyExpr

let ((lctx, localInsts, type), s) ← (unquoteForMatch argTyExpr).run { mayPostpone := (← read).mayPostpone }
let (pat, patVarDecls, newLevels) ← elabPat pat lctx localInsts type s.levelNames
Expand Down
10 changes: 8 additions & 2 deletions Qq/MetaM.lean
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ def trySynthInstanceQ (α : Q(Sort u)) : MetaM (LOption Q($α)) := do
def synthInstanceQ (α : Q(Sort u)) : MetaM Q($α) := do
synthInstance α

def instantiateMVarsQ {α : Q(Sort u)} (e : Q($α)) : MetaM Q($α) := do
instantiateMVars e
/-- `Lean.instantiateMVars`, with the guarantee that the result is defeq to the original. -/
def instantiateMVarsQ {α : Q(Sort u)} (e : Q($α)) : MetaM ((e' : Q($α)) ×' $e' =Q $e) :=
return ⟨← instantiateMVars e, ⟨⟩⟩

set_option linter.unusedVariables false in
/-- `Lean.instantiateLevelMVars`, with the guarantee that the result is defeq to the original. -/
def instantiateLevelMVarsQ (u : Level) : MetaM ((u' : Level) ×' u' =QL u) :=
return ⟨← instantiateLevelMVars u, ⟨⟩⟩

def elabTermEnsuringTypeQ (stx : Syntax) (expectedType : Q(Sort u))
(catchExPostpone := true) (implicitLambda := true) (errorMsgHeader? : Option String := none) :
Expand Down

0 comments on commit cc24b34

Please sign in to comment.