Skip to content

Commit

Permalink
small change
Browse files Browse the repository at this point in the history
  • Loading branch information
kmill committed Dec 29, 2024
1 parent 51d6b6f commit 1599c23
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Lean/Elab/Deriving/ToExpr.lean
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ def mkAppNTerm (f : Term) (args : Array Term) : MetaM Term :=

/-- Fixes the output of `mkInductiveApp` to explicitly reference universe levels. -/
def updateIndType (indVal : InductiveVal) (t : Term) : TermElabM Term :=
let levels := indVal.levelParams.toArray.map mkIdent
match t with
| `(@$f $args*) =>
let levels := indVal.levelParams.toArray.map mkIdent
`(@$f.{$levels,*} $args*)
| `(@$f $args*) => `(@$f.{$levels,*} $args*)
| _ => throwError "(internal error) expecting output of `mkInductiveApp`"

/--
Expand Down Expand Up @@ -121,9 +120,7 @@ These are very simple fields, so avoiding the duplication is not worth it.
def mkLocalInstanceLetDecls (ctx : Deriving.Context) (argNames : Array Name) (levelInsts : Array Term) :
TermElabM (Array (TSyntax ``Parser.Term.letDecl)) := do
let mut letDecls := #[]
for i in [:ctx.typeInfos.size] do
let indVal := ctx.typeInfos[i]!
let auxFunName := ctx.auxFunNames[i]!
for indVal in ctx.typeInfos, auxFunName in ctx.auxFunNames do
let currArgNames ← mkInductArgNames indVal
let numParams := indVal.numParams
let currIndices := currArgNames[numParams:]
Expand All @@ -132,7 +129,7 @@ def mkLocalInstanceLetDecls (ctx : Deriving.Context) (argNames : Array Name) (le
let indType ← mkInductiveApp indVal argNamesNew
let instName ← mkFreshUserName `localinst
let toTypeExpr ← mkToTypeExpr indVal argNames
-- Recall that each type uses the same universe levels.
-- Recall that mutually inductive types all use the same universe levels.
let letDecl ← `(Parser.Term.letDecl| $(mkIdent instName):ident $binders:implicitBinder* : ToExpr $indType :=
{ toExpr := $(mkIdent auxFunName) $levelInsts*, toTypeExpr := $toTypeExpr })
letDecls := letDecls.push letDecl
Expand Down

0 comments on commit 1599c23

Please sign in to comment.