Given
```lean
structure A where
x : Nat
structure B extends A where
y : Nat
```
rather than pretty printing `{ x := 1, y := 2 : B }` as `{ toA := { x :=
1 }, y := 2 }`, it now pretty prints as `{ x := 1, y := 2 }`.
The option `pp.structureInstances.flatten` controls whether to flatten
structure instances like this.
55 lines
974 B
Text
55 lines
974 B
Text
/-!
|
|
# Delaborating structure instances
|
|
-/
|
|
|
|
structure A where
|
|
x : Nat
|
|
|
|
structure B extends A where
|
|
y : Nat
|
|
|
|
/-!
|
|
Check flattening of parent structures.
|
|
-/
|
|
|
|
/-- info: { x := 1 } : A -/
|
|
#guard_msgs in #check {x := 1 : A}
|
|
|
|
/-- info: { x := 1, y := 2 } : B -/
|
|
#guard_msgs in #check {x := 1, y := 2 : B}
|
|
|
|
/-!
|
|
No flattening of parent structures
|
|
-/
|
|
section
|
|
set_option pp.structureInstances.flatten false
|
|
|
|
/-- info: { x := 1 } : A -/
|
|
#guard_msgs in #check {x := 1 : A}
|
|
|
|
/-- info: { toA := { x := 1 }, y := 2 } : B -/
|
|
#guard_msgs in #check {x := 1, y := 2 : B}
|
|
end
|
|
|
|
/-!
|
|
Not a true parent structure, so no flattening.
|
|
-/
|
|
|
|
structure B' where
|
|
toA : A
|
|
y : Nat
|
|
|
|
/-- info: { toA := { x := 1 }, y := 2 } : B' -/
|
|
#guard_msgs in #check {toA := {x := 1}, y := 2 : B'}
|
|
|
|
/-!
|
|
Check that this handles parameters.
|
|
-/
|
|
structure C (n : Nat) where
|
|
x : Fin n
|
|
|
|
structure D (n : Nat) extends C n where
|
|
y : Nat
|
|
|
|
/-- info: { x := 1, y := 2 } : D 3 -/
|
|
#guard_msgs in #check {x := 1, y := 2 : D 3}
|