RFC: pretty printing dot notation with `CoeFun`
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Description
In the wake of #1910 , it has become possible to use dot notation with namespaced non-function declarations.
However, pretty printing doesn't show these terms as using dot notation.
adapting the example given for that issue:
structure Equiv (α β : Sort _) where
toFun : α → β
invFun : β → α
infixl:25 " ≃ " => Equiv
instance: CoeFun (α ≃ β) fun _ => α → β where
coe := Equiv.toFun
def Foo := Nat
def Bar := Nat
def Foo.toBar : Foo ≃ Bar := ⟨id, id⟩
variable (f : Foo)
#check f.toBar -- Foo.toBar f : Bar
ideally, the latter #check command should display f.toBar by default.
Just as dot notation improves the experience of writing and reading code, pretty printing this new instance of dot notation will allow users to more clearly see the structure of code by hiding redundant information, i.e. the namespace of the declaration.
Community Feedback
This initiative started because all porting notes referring to #1910 in mathlib came under review, and some of them mentioned that certain uses of the pp_nodot attribute were not useful yet because the dot notation wasn't available for the declarations the porting notes were referring to. See also this discussion on Zulip.
Impact
Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided Lean example and inspect the pretty-printing path for the #check f.toBar output, using the linked #1910 issue and Zulip discussion for context. Done means the command displays f.toBar by default while preserving existing dot-notation output.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100