lean4-htt/tests/lean/lcnfTypes.lean.expected.out
Kyle Miller 6e408ee402
feat: apply app unexpanders for all prefixes of an application (#3375)
Before, app unexpanders would only be applied to entire applications.
However, some notations produce functions, and these functions can be
given additional arguments. The solution so far has been to write app
unexpanders so that they can take an arbitrary number of additional
arguments. However, as reported in [this Zulip
thread](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/pretty.20printer.20bug/near/420662236),
this leads to misleading hover information in the Infoview. For example,
while `HAdd.hAdd f g 1` pretty prints as `(f + g) 1`, hovering over `f +
g` shows `f`. There is no way to fix the situation from within an app
unexpander; the expression position for `HAdd.hAdd f g` is absent, and
app unexpanders cannot register TermInfo.

This commit changes the app delaborator to try running app unexpanders
on every prefix of an application, from longest to shortest prefix. For
efficiency, it is careful to only try this when app delaborators do in
fact exist for the head constant, and it also ensures arguments are only
delaborated once. Then, in `(f + g) 1`, the `f + g` gets TermInfo
registered for that subexpression, making it properly hoverable.

The app delaborator is also refactored, and there are some bug fixes:
- app unexpanders only run when `pp.explicit` is false
- trailing parameters in under-applied applications are now only
considered up to reducible & instance transparency, which lets, for
example, optional arguments for `IO`-valued functions to be omitted.
(`IO` is a reader monad, so it's hiding a pi type)
- app unexpanders will no longer run for delaborators that use
`withOverApp`
- auto parameters now always pretty print, since we are not verifying
that the provided argument equals the result of evaluating the tactic

Furthermore, the `notation` command has been modified to generate an app
unexpander that relies on the app delaborator's new behavior.

The change to app unexpanders is reverse-compatible, but it's
recommended to update `@[app_unexpander]`s in downstream projects so
that they no longer handle overapplication themselves.
2024-02-27 07:04:17 +00:00

66 lines
4.2 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.

Vec.zip : {α : Type u_1} → {n : Nat} → {β : Type u_2} → Vec α ◾ → Vec β ◾ → Vec (α × β) ◾
mkConstTuple : {α : Type u_1} → α → Nat → ◾
Fin.add : {n : Nat} → Fin ◾ → Fin ◾ → Fin ◾
Vec.cons : {α : Type u} → {n : Nat} → α → Vec α ◾ → Vec α
Eq.rec : {α : Sort u_1} → {a : α} → {motive : α → ◾ → Sort u} → motive ◾ ◾ → {a : α} → ◾ → motive ◾ ◾
GetElem.getElem : {cont : Type u} →
{idx : Type v} →
{elem : Type w} → {dom : cont → idx → Prop} → [self : GetElem cont idx elem ◾] → cont → idx → ◾ → elem
Term.constFold : {ctx : List Ty} → {ty : Ty} → Term ◾ ◾ → Term ◾ ◾
Term.denote : {ctx : List Ty} → {ty : Ty} → Term ◾ ◾ → HList ◾ ◾ → ◾
HList.get : {α : Type u_1} → {β : α → Type u_2} → {is : List α} → {i : α} → HList β ◾ → Member ◾ ◾ → β ◾
Member.head : {α : Type u_1} → {a : α} → {as : List α} → Member ◾ ◾
Ty.denote : Ty → Type
MonadControl.liftWith : {m : Type u → Type v} →
{n : Type u → Type w} → [self : MonadControl m n] → {α : Type u} → (({β : Type u} → n β → m ◾) → m α) → n α
MonadControl.restoreM : {m : Type u → Type v} → {n : Type u → Type w} → [self : MonadControl m n] → {α : Type u} → m ◾ → n α
Decidable.casesOn : {p : Prop} → {motive : Decidable ◾ → Sort u} → Decidable ◾ → (◾ → motive ◾) → (◾ → motive ◾) → motive ◾
Lean.getConstInfo : {m : Type → Type} →
[inst : Monad m] → [inst : Lean.MonadEnv m] → [inst : Lean.MonadError m] → Lean.Name → m Lean.ConstantInfo
Lean.Meta.instMonadMetaM : Monad fun α =>
Lean.Meta.Context →
ST.Ref PUnit Lean.Meta.State →
Lean.Core.Context → ST.Ref PUnit Lean.Core.State → PUnit → EStateM.Result Lean.Exception PUnit α
Lean.Meta.inferType : Lean.Expr →
Lean.Meta.Context →
ST.Ref PUnit Lean.Meta.State →
Lean.Core.Context → ST.Ref PUnit Lean.Core.State → PUnit → EStateM.Result Lean.Exception PUnit Lean.Expr
Lean.Elab.Term.elabTerm : Lean.Syntax →
Option Lean.Expr →
Bool →
Bool →
Lean.Elab.Term.Context →
ST.Ref PUnit Lean.Elab.Term.State →
Lean.Meta.Context →
ST.Ref PUnit Lean.Meta.State →
Lean.Core.Context → ST.Ref PUnit Lean.Core.State → PUnit → EStateM.Result Lean.Exception PUnit Lean.Expr
Nat.add : Nat → Nat → Nat
Magma.mul : Magma → ◾ → ◾ → ◾
weird1 : Bool → ◾
lamAny₁ : Bool → Monad ◾
lamAny₂ : Bool → Monad ◾
Term.constFold : List Ty → Ty → Term lcErased lcErased → Term lcErased lcErased
Term.denote : List Ty → Ty → Term lcErased lcErased → HList Ty lcErased lcErased → lcErased
HList.get : lcErased →
lcErased → List lcErased → lcErased → HList lcErased lcErased lcErased → Member lcErased lcErased lcErased → lcErased
Member.head : lcErased → lcErased → List lcErased → Member lcErased lcErased lcErased
Ty.denote : lcErased
MonadControl.liftWith : lcErased →
lcErased → MonadControl lcErased lcErased → lcErased → ((lcErased → lcErased → lcErased) → lcErased) → lcErased
MonadControl.restoreM : lcErased → lcErased → MonadControl lcErased lcErased → lcErased → lcErased → lcErased
Decidable.casesOn : lcErased → lcErased → Bool → (lcErased → lcErased) → (lcErased → lcErased) → lcErased
Lean.getConstInfo : lcErased → Monad lcErased → Lean.MonadEnv lcErased → Lean.MonadError lcErased → Lean.Name → lcErased
Lean.Meta.instMonadMetaM : Monad lcErased
Lean.Meta.inferType : Lean.Expr →
Lean.Meta.Context → lcErased → Lean.Core.Context → lcErased → PUnit → EStateM.Result Lean.Exception PUnit Lean.Expr
Lean.Elab.Term.elabTerm : Lean.Syntax →
Option Lean.Expr →
Bool →
Bool →
Lean.Elab.Term.Context →
lcErased →
Lean.Meta.Context →
lcErased → Lean.Core.Context → lcErased → PUnit → EStateM.Result Lean.Exception PUnit Lean.Expr
Nat.add : Nat → Nat → Nat
Fin.add : Nat → Nat → Nat → Nat
Lean.HashSetBucket.update : lcErased → Array (List lcErased) → USize → List lcErased → lcErased → Array (List lcErased)