This PR improves the `#print` command for structures to show all fields
and which parents the fields were inherited from, hiding internal
details such as which parents are represented as subobjects. This
information is still present in the constructor if needed. The pretty
printer for private constants is also improved, and it now handles
private names from the current module like any other name; private names
from other modules are made hygienic.
Example output for `#print Monad`:
```
class Monad.{u, v} (m : Type u → Type v) : Type (max (u + 1) v)
number of parameters: 1
parents:
Monad.toApplicative : Applicative m
Monad.toBind : Bind m
fields:
Functor.map : {α β : Type u} → (α → β) → m α → m β
Functor.mapConst : {α β : Type u} → α → m β → m α
Pure.pure : {α : Type u} → α → m α
Seq.seq : {α β : Type u} → m (α → β) → (Unit → m α) → m β
SeqLeft.seqLeft : {α β : Type u} → m α → (Unit → m β) → m α
SeqRight.seqRight : {α β : Type u} → m α → (Unit → m β) → m β
Bind.bind : {α β : Type u} → m α → (α → m β) → m β
constructor:
Monad.mk.{u, v} {m : Type u → Type v} [toApplicative : Applicative m] [toBind : Bind m] : Monad m
resolution order:
Monad, Applicative, Bind, Functor, Pure, Seq, SeqLeft, SeqRight
```
Suggested by Floris van Doorn [on
Zulip](https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/.23print.20command.20for.20structures/near/482503637).
29 lines
699 B
Text
29 lines
699 B
Text
/-- info: { val := { toBitVec := { toFin := ⟨0, ⋯⟩ } }, valid := ⋯ } -/
|
|
#guard_msgs in
|
|
#reduce Char.ofNat (nat_lit 0)
|
|
|
|
/--
|
|
info: { val := { toBitVec := { toFin := ⟨0, isValidChar_UInt32✝ (Or.inl (Nat.le_of_ble_eq_true rfl))⟩ } },
|
|
valid := Or.inl (Nat.le_of_ble_eq_true rfl) }
|
|
-/
|
|
#guard_msgs in
|
|
set_option pp.proofs true in
|
|
#reduce Char.ofNat (nat_lit 0)
|
|
|
|
/-- info: 2 = 1 + 1 -/
|
|
#guard_msgs in
|
|
#reduce 2 = 1 + 1
|
|
|
|
/-- info: 2 = 2 -/
|
|
#guard_msgs in
|
|
#reduce (types := true) 2 = 1 + 1
|
|
|
|
/-- info: Eq.refl (2 + 2) -/
|
|
#guard_msgs in
|
|
set_option pp.proofs true in
|
|
#reduce Eq.refl (2+2)
|
|
|
|
/-- info: Eq.refl 4 -/
|
|
#guard_msgs in
|
|
set_option pp.proofs true in
|
|
#reduce (proofs := true) Eq.refl (2+2)
|