lean4-htt/tests/lean/delabProjectionApp.lean
Kyle Miller a706c3b89a
feat: delaboration collapses parent projections (#3326)
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.
2024-02-14 23:44:48 +00:00

93 lines
1.1 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-!
# 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