lean4-htt/tests/lean/delabApp.lean
Kyle Miller c394a834c3
feat: extract delabAppCore, define withOverApp, and make over-applied projections pretty print (#3083)
To handle delaborating notations that are functions that can be applied
to arguments, extracts the core function application delaborator as a
separate function that accepts the number of arguments to process and a
delaborator to apply to the "head" of the expression.

Defines `withOverApp`, which has the same interface as the combinator of
the same name from std4, but it uses this core function application
delaborator.

Uses `withOverApp` to improve a number of application delaborators,
notably projections. This means Mathlib can stop using `pp_dot` for
structure fields that have function types.

Incidentally fixes `getParamKinds` to specialize default values to use
supplied arguments, which impacts how default arguments are delaborated.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-01-10 13:24:28 +00:00

39 lines
729 B
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.

/-!
# Testing features of the app delaborator, including overapplication
-/
/-!
Check that the optional value equality check is specialized to the supplied arguments
(rather than, formerly, the locally-defined fvars from a telescope).
-/
def foo (α : Type) [Inhabited α] (x : α := default) : α := x
#check foo Nat
#check foo Nat 1
/-!
Check that overapplied projections pretty print using projection notation.
-/
structure Foo where
f : Nat → Nat
#check ∀ (x : Foo), x.f 1 = 0
/-!
Overapplied `letFun`
-/
#check (have f := id; f) 1
/-!
Overapplied `OfNat.ofNat`
-/
instance : OfNat (Nat → Nat) 1 where
ofNat := id
#check (1 : Nat → Nat) 2
/-!
Overapplied `dite`
-/
#check (if h : True then id else id) 1