-
Notifications
You must be signed in to change notification settings - Fork 85
Refactor new mode syntax #3522
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
Refactor new mode syntax #3522
Conversation
Parser Change ChecklistThis PR modifies the parser. Please check that the following tests are updated:
This test should have examples of every new bit of syntax you are adding. Feel free to just check the box if your PR does not actually change the syntax (because it is refactoring the parser, say). |
fa57c78
to
2aa68b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit sad that this PR is 3 different changes in one, but all in heavily overlapping code:
- switching
local_ x @ portable
tox @ local portable
- switching
(x : t @@ local)
to(x : t @ local)
- changes some logic related to curry syntax? not sure what this is about.
Alas, thing at least looked reasonable on my first pass. Left some comments.
Thanks for the review.
Yeah I agree this is sad; but also due to the overlapping, it wouldn't make sense to separate them into PRs. |
Note to myself: add default modalities to |
This PR refactors the new mode syntax (
@
and@@
).@
always means modes, and@@
always mean modalities. Previously,@@
can mean modes in some position for disambiguition. For example,x : a -> a @@ local
saysx
is local, andx : b -> a @ local
saysa
is local). After this PR, the first example will writex : (a -> a) @ local
. The second example doesn't change. You can also writex : a @ local
.local_ a @ portable -> b
will print backa @ local portable -> b
, whilelocal_ a -> b
prints back the same. The idea is that "if the user already knows about and uses the new mode syntax, then we should print back new mode syntax". This is done in bothpprintast.ml
andprinttyp.ml
.fun a b : ty @@ modes -> ..
was introduced by Supports mode annotation on function body #3327 , and would be changed tofun a b : ty @ modes -> ..
. Note the ambiguity: the arrow could be arrow type. We decide to remove this for simplicity.parser.mly
andpprintast.ml
, so that some missing corner cases are covered, and diff to the upstream is minimized. For example,labeled_simple_pattern
is now almost identical to upstream. This allows systematic enumeration of all possible syntax, which helps with user documentation, and test coverage.source_jane_street.ml
is rewritten to cover all possible syntax.Suggestions to reviewers
source_jane_street.ml
, to get a sense of the new syntax (don't look at the type errors - they are fine).parser.mly
.pprintast.ml
andprinttyp.ml
. The former should be functionally "most fine" as tested bysource_jane_street.ml
, but other aspects such as coding style should be inspected.source_jane_street.ml
, are all mechanical and can be skipped.