-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
diff --git a/Lens/Elab.lean b/Lens/Elab.lean
index 9d9c1bc..98a708d 100644
--- a/Lens/Elab.lean
+++ b/Lens/Elab.lean
@@ -21,12 +21,9 @@ elab "makeLenses" structIdent:ident : command => do
let fieldNameIdent := mkIdent field.fieldName
let some decl := env.find? (field.projFn)
| throwErrorAt structIdent s!"Could not find project function {field.projFn}"
- let (some fieldTypeName, some fieldTypeArgs) := (← liftTermElabM (liftMetaM (
- forallTelescope decl.type fun _ body
- => pure (body.getAppFn.constName?, body.getAppArgs.mapM (·.constName?)))))
- | throwErrorAt structIdent "Not a structure name"
- let d ← fieldTypeArgs.mapM fun argName => `($(mkIdent argName))
- let fieldTypeNameIdent := Syntax.mkCApp fieldTypeName d
+ let fieldTypeNameIdent : Term ← liftTermElabM <| liftMetaM <|
+ forallTelescope decl.type fun _ body =>
+ Lean.PrettyPrinter.delab body
let lensName := mkIdent field.fieldName
let newVal := mkIdent <| Name.mkSimple "newVal"
let l ←