feat: look for builtin type instances
parent
664a86e08b
commit
e402ee94b1
|
@ -16,11 +16,14 @@ open Lean Meta
|
||||||
def getInstanceTypes (typ : Expr) : MetaM (Array Name) := do
|
def getInstanceTypes (typ : Expr) : MetaM (Array Name) := do
|
||||||
let (_, _, tail) ← forallMetaTelescopeReducing typ
|
let (_, _, tail) ← forallMetaTelescopeReducing typ
|
||||||
let args := tail.getAppArgs
|
let args := tail.getAppArgs
|
||||||
let (_, bar) ← args.mapM (Expr.forEach · findName) |>.run .empty
|
let (_, names) ← args.mapM (Expr.forEach · findName) |>.run .empty
|
||||||
pure bar
|
return names
|
||||||
where
|
where
|
||||||
findName : Expr → StateRefT (Array Name) MetaM Unit
|
findName : Expr → StateRefT (Array Name) MetaM Unit
|
||||||
| .const name _ => do set <| (←get).push name
|
| .const name _ => modify (·.push name)
|
||||||
|
| .sort .zero => modify (·.push "_builtin_prop")
|
||||||
|
| .sort (.succ _) => modify (·.push "_builtin_typeu")
|
||||||
|
| .sort _ => modify (·.push "_builtin_sortu")
|
||||||
| _ => pure ()
|
| _ => pure ()
|
||||||
|
|
||||||
def InstanceInfo.ofDefinitionVal (v : DefinitionVal) : MetaM InstanceInfo := do
|
def InstanceInfo.ofDefinitionVal (v : DefinitionVal) : MetaM InstanceInfo := do
|
||||||
|
@ -30,7 +33,7 @@ def InstanceInfo.ofDefinitionVal (v : DefinitionVal) : MetaM InstanceInfo := do
|
||||||
info := { info with attrs := info.attrs.push instAttr }
|
info := { info with attrs := info.attrs.push instAttr }
|
||||||
let typeNames ← getInstanceTypes v.type
|
let typeNames ← getInstanceTypes v.type
|
||||||
|
|
||||||
pure {
|
return {
|
||||||
toDefinitionInfo := info,
|
toDefinitionInfo := info,
|
||||||
className,
|
className,
|
||||||
typeNames
|
typeNames
|
||||||
|
|
Loading…
Reference in New Issue