feat: print number of parameters for an inductive type

This commit is contained in:
Leonardo de Moura 2022-03-08 16:08:06 -08:00
parent 7b84b4cdaa
commit 234046521a
4 changed files with 5 additions and 0 deletions

View file

@ -56,6 +56,7 @@ private def printQuot (kind : QuotKind) (id : Name) (levelParams : List Name) (t
private def printInduct (id : Name) (levelParams : List Name) (numParams : Nat) (numIndices : Nat) (type : Expr)
(ctors : List Name) (isUnsafe : Bool) : CommandElabM Unit := do
let mut m ← mkHeader' "inductive" id levelParams type isUnsafe
m := m ++ Format.line ++ "number of parameters: " ++ toString numParams
m := m ++ Format.line ++ "constructors:"
for ctor in ctors do
let cinfo ← getConstInfo ctor

View file

@ -3,6 +3,7 @@ diamond1.lean:11:40-11:45: error: parent field type mismatch, field 'a' from par
but is expected to have type
α : Type
inductive Foo : Type → Type
number of parameters: 1
constructors:
Foo.mk : {α : Type} → Bar (αα) → (Bool → α) → Nat → Foo α
def f : Nat → Foo Nat :=

View file

@ -1,3 +1,4 @@
inductive Semiring.{u} : Type u → Type u
number of parameters: 1
constructors:
Semiring.mk : {R : Type u} → [toAddCommMonoid : AddCommMonoid R] → [toMonoid : Monoid R] → Semiring R

View file

@ -1,8 +1,10 @@
inductive Foo.{v, u_1} : {α : Sort u_1} → (α → Type v) → Sort (max u_1 (v + 1))
number of parameters: 2
constructors:
Foo.mk : {α : Sort u_1} → {β : α → Type v} → (a : α) → β a → Foo β
structAutoBound.lean:9:15-9:16: error: a universe level named 'u' has already been declared
inductive Boo.{u, v} : Type u → Type v → Type (max u v)
number of parameters: 2
constructors:
Boo.mk : {α : Type u} → {β : Type v} → α → β → Boo α β
structAutoBound.lean:18:0-20:7: error: unused universe parameter 'w'