feat: print nameless instances properly
parent
3c80369cca
commit
b0319462f1
|
@ -30,7 +30,10 @@ def argToHtml (arg : Arg) : HtmlM Html := do
|
|||
| BinderInfo.implicit => ("{", "}", true)
|
||||
| BinderInfo.strictImplicit => ("⦃", "⦄", true)
|
||||
| BinderInfo.instImplicit => ("[", "]", true)
|
||||
let mut nodes := #[Html.text s!"{l}{arg.name.toString} : "]
|
||||
let mut nodes :=
|
||||
match arg.name with
|
||||
| some name => #[Html.text s!"{l}{name.toString} : "]
|
||||
| none => #[Html.text s!"{l}"]
|
||||
nodes := nodes.append (← infoFormatToHtml arg.type)
|
||||
nodes := nodes.push r
|
||||
let inner := <span class="fn">[nodes]</span>
|
||||
|
|
|
@ -27,14 +27,16 @@ structure NameInfo where
|
|||
doc : Option String
|
||||
deriving Inhabited
|
||||
|
||||
|
||||
/--
|
||||
An argument to a declaration, e.g. the `(x : Nat)` in `def foo (x : Nat) := x`.
|
||||
-/
|
||||
structure Arg where
|
||||
/--
|
||||
The name of the argument.
|
||||
The name of the argument. For auto generated argument names like `[Monad α]`
|
||||
this is none
|
||||
-/
|
||||
name : Name
|
||||
name : Option Name
|
||||
/--
|
||||
The pretty printed type of the argument.
|
||||
-/
|
||||
|
|
|
@ -15,17 +15,20 @@ def NameInfo.ofTypedName (n : Name) (t : Expr) : MetaM NameInfo := do
|
|||
let env ← getEnv
|
||||
return { name := n, type := ← prettyPrintTerm t, doc := ← findDocString? env n}
|
||||
|
||||
partial def typeToArgsType (e : Expr) : (Array (Name × Expr × BinderInfo) × Expr) :=
|
||||
partial def typeToArgsType (e : Expr) : (Array ((Option Name) × Expr × BinderInfo) × Expr) :=
|
||||
let helper := fun name type body data =>
|
||||
-- Once we hit a name with a macro scope we stop traversing the expression
|
||||
-- and print what is left after the : instead. The only exception
|
||||
-- to this is instances since these almost never have a name
|
||||
-- but should still be printed as arguments instead of after the :.
|
||||
if name.hasMacroScopes && !data.isInstImplicit then
|
||||
if data.isInstImplicit then
|
||||
let arg := (none, type, data)
|
||||
let (args, final) := typeToArgsType (Expr.instantiate1 body (mkFVar ⟨name⟩))
|
||||
(#[arg] ++ args, final)
|
||||
else if name.hasMacroScopes then
|
||||
(#[], e)
|
||||
else
|
||||
let name := name.eraseMacroScopes
|
||||
let arg := (name, type, data)
|
||||
let arg := (some name, type, data)
|
||||
let (args, final) := typeToArgsType (Expr.instantiate1 body (mkFVar ⟨name⟩))
|
||||
(#[arg] ++ args, final)
|
||||
match e.consumeMData with
|
||||
|
|
Loading…
Reference in New Issue