Skip to content

Commit

Permalink
doc: explain app_delab (#6450)
Browse files Browse the repository at this point in the history
This PR adds a docstring to the `@[app_delab]` attribute.

---------

Co-authored-by: Kyle Miller <[email protected]>
  • Loading branch information
eric-wieser and kmill authored Dec 29, 2024
1 parent 536c6a8 commit 11eea84
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Lean/PrettyPrinter/Delaborator/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ unsafe def mkDelabAttribute : IO (KeyedDeclsAttribute Delab) :=
} `Lean.PrettyPrinter.Delaborator.delabAttribute
@[builtin_init mkDelabAttribute] opaque delabAttribute : KeyedDeclsAttribute Delab

/--
`@[app_delab c]` registers a delaborator for applications with head constant `c`.
Such delaborators also apply to the constant `c` itself (known as a "nullary application").
This attribute should be applied to definitions of type `Lean.PrettyPrinter.Delaborator.Delab`.
When defining delaborators for constant applications, one should prefer this attribute over `@[delab app.c]`,
as `@[app_delab c]` first performs name resolution on `c` in the current scope.
-/
macro "app_delab" id:ident : attr => do
match ← Macro.resolveGlobalName id.getId with
| [] => Macro.throwErrorAt id s!"unknown declaration '{id.getId}'"
Expand Down

0 comments on commit 11eea84

Please sign in to comment.