Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: return QuotedDefEq from Meta wrappers #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading