When projection functions are delaborated, intermediate parent projections are no longer printed. For example, rather than pretty printing as `o.toB.toA.x` with these `toB` and `toA` parent projections, it pretty prints as `o.x`. This feature is being upstreamed from mathlib.
93 lines
1.1 KiB
Text
93 lines
1.1 KiB
Text
/-!
|
||
# Delaboration of projection functions
|
||
-/
|
||
|
||
structure A where
|
||
x : Nat
|
||
|
||
structure B extends A where
|
||
y : Nat
|
||
|
||
structure C extends B where
|
||
z : Nat
|
||
|
||
variable (a : A) (b : B) (c : C)
|
||
|
||
section
|
||
/-!
|
||
Checking projection delaboration, including parent projection collapse.
|
||
-/
|
||
|
||
#check a.x
|
||
#check b.x
|
||
#check c.x
|
||
|
||
#check b.y
|
||
#check c.y
|
||
|
||
#check c.z
|
||
|
||
end
|
||
|
||
section
|
||
/-!
|
||
Checking `pp.structureProjections` can turn off this delaborator.
|
||
-/
|
||
|
||
set_option pp.structureProjections false
|
||
|
||
#check a.x
|
||
#check b.x
|
||
#check c.x
|
||
|
||
#check b.y
|
||
#check c.y
|
||
|
||
#check c.z
|
||
|
||
end
|
||
|
||
structure Fin' extends Fin 5
|
||
|
||
structure Fin'' (n : Nat) extends Fin n
|
||
|
||
structure D (n : Nat) extends A
|
||
|
||
variable (x : Fin 5) (y : Fin') (z : Fin'' 5) (d : D 5)
|
||
|
||
section
|
||
/-!
|
||
Checking handling of parameters.
|
||
-/
|
||
|
||
#check x.val
|
||
#check y.val
|
||
#check z.val
|
||
#check d.x
|
||
|
||
end
|
||
|
||
section
|
||
/-!
|
||
Check handling of parameters when `pp.explicit` is true.
|
||
-/
|
||
set_option pp.explicit true
|
||
|
||
#check c.x
|
||
#check x.val
|
||
#check y.val
|
||
#check z.val
|
||
#check d.x
|
||
|
||
end
|
||
|
||
structure Fn (α β : Type) where
|
||
toFun : α → β
|
||
|
||
variable (f : Fn Nat Int)
|
||
|
||
/-!
|
||
Check overapplication.
|
||
-/
|
||
|
||
#check f.toFun 0
|