Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(src/frontends): order notation by priority in pretty-printer #207

Merged
merged 1 commit into from May 1, 2020

Conversation

Vierkantor
Copy link
Collaborator

If you have a notation for a special case, e.g. finset.sum finset.univ, and a notation for a general case, e.g. finset.sum, you can now give the special-cased notation a higher priority to ensure it is used by the pretty-printer when applicable.

When deciding how to pretty-print an expression, Lean looks up the notations associated to the head of the expression. It tries them one-by-one until it finds a notation that matches the expression. The order in which they are tried used to be the definition order. This PR changes this ordering to have higher-priority notations first.

Although notation_entry.priority() is also used by the parser, it doesn't seem to be set at all in mathlib. I expect that there will be no conflicts between the usage of priority in the parser and in the pretty-printer.

If you have a notation for a special case, e.g. `finset.sum finset.univ`, and a
notation for a general case, e.g. `finset.sum`, you can now give the
special-cased notation a higher priority to ensure it is used by the
pretty-printer when applicable.

When deciding how to pretty-print an expression, Lean looks up the notations
associated to the head of the expression. It tries them one-by-one until it
finds a notation that matches the expression. The order in which they are tried
used to be the definition order. This PR changes this ordering to have
higher-priority notations first.

Although `notation_entry.priority()` is also used by the parser, it doesn't
seem to be set at all in mathlib. I expect that there will be no conflicts
between the usage of `priority` in the parser and in the pretty-printer.
Copy link
Member

@gebner gebner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Will merge if tests pass.

@gebner gebner added this to the Lean 3.10 milestone May 1, 2020
@gebner gebner merged commit 14c0fb3 into master May 1, 2020
@gebner gebner deleted the notation_pp_priority branch May 8, 2020 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants