Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a patch for an upcoming release of ppxlib where the internal AST is bumped from 4.14 to 5.2. Until that is merged and released, there is no reason to merge this PR.
The most notable change is the representation of functions in the AST.
Functions
Currently
In the parsetree currently, functions like:
Are represented roughly as
Functions like:
Are represented roughly as
Since 5.2
All of these functions now map to a single AST node
Pexp_function
(note, this is the same name as the old cases function). The first argument is a list of parameters meaning:Now looks like:
Pexp_function([x; y; z], _constraint, body)
And the
body
is where we can either have more expressions (Pfunction_body _
) or cases (Pfunction_cases _
). That means:Has an empty list of parameters:
Local Module Opens for Types
Another feature added in 5.2 was the ability to locally open modules in type definitions.
This has a
Ptyp_open (module_identifier, core_type)
AST node. Just like normal module opens this does create some syntactic ambiguity about where things come from inside the parentheses. The approach of these patches is to locally open the same module in any code that is generated.This PR assumes
ppxlib.0.35.0
will be the ppxlib that contains the 5.2 AST bump.ppxlib.0.34.0
will likely be the stable release of ppxlib with 5.3 support. This definitely might change, and the PR should be updated accordingly.