Prepare for 5.2 AST in Ppxlib #160
Conversation
|
Thanks! I'll merge and release as soon as the deps problem is fixed. Seems we need a few ppxlib.0.36 compatible packages before this one's able to build! |
|
Could you add a pin-depends on |
|
It just got merged so that won't be necessary! |
|
Just added a changelog entry, this should also trigger a new build which will hopefully pick |
|
It seems we still break the Ptyp_poly invariant somewhere! |
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
|
Darn it, it seems our own ast_helper function is biting us here. Maybe we can change it to: let poly ?loc ?attrs a b =
if a = [] then b
else mk ?loc ?attrs (Ptyp_poly (a, b))I know we're also floating the idea of getting rid of ast_helper altogether though and perhaps this is a good opportunity to start doing that! |
|
I'm fixing it as we speak, I'm replacing |
|
Yes, we should remove Ast_helper entirely at some point! Let's start deprecating it. I just realized it even has the following function: and that's exposed... |
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
|
We both needed a rebase AND to fix a few extra ptyp_poly ([], ...) that I somehow missed in #162 ! |
|
I see there are a few more calls to |
|
Are you sure? I can't find anymore of those with |
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
bodyis 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.0will be the ppxlib that contains the 5.2 AST bump.ppxlib.0.34.0will likely be the stable release of ppxlib with 5.3 support. This definitely might change, and the PR should be updated accordingly.