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

What replaced ocaml-migrate-parsetree Versions.migrate? #339

Open
mbacarella opened this issue May 13, 2022 · 2 comments
Open

What replaced ocaml-migrate-parsetree Versions.migrate? #339

mbacarella opened this issue May 13, 2022 · 2 comments

Comments

@mbacarella
Copy link

Suppose you have code that uses ppx_tools_versioned and ocaml-migrate-parsetree. The code builds up an Ast_404 parsetree and then, as a last step, when it comes time to generate .ml and .mli files from the AST, it runs Version.migrate Versions.ocaml_404 Versions.ocaml_current.

I'm attempting to port this code to ppxlib but I'm having trouble finding the Versions.migrate. Is this still provided? I notice there's a lot of macro stuff so maybe my grepping misses it.

If it's no longer provided, what should be done instead?

Thank you kindly!

@pitag-ha
Copy link
Member

Hi @mbacarella, thanks for porting your ppx to ppxlib! When you use ppxlib, the migration is done by ppxlib itself, so you don't need to do anything in that regard. You'll just need to use ppxlib to write your AST node(s). For that, you can use -from highest level to lowest level- metaquot, Ast_builder (which is similar to the former Ast_helper which you might know) or build the nodes directly. All three options produce nodes in the AST version from the latest released compiler (currently 4.14).

Whenever your ppxlib PPX is used in a project, ppxlib takes care of migrating the AST of the project to the latest AST version, then applies your PPX and then migrates the AST back to the version it came from.

Does that answer your question?

@mbacarella
Copy link
Author

Thanks for the answer. This is helpful. A question on future compatibility: I assume the ppxlib exposed AST cannot know what future versions of OCaml will have, so it's possible to support new versions of OCaml in ppxlib, a backward incompatible change to the AST will be required and thusly ppxlib users will need updating?

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

No branches or pull requests

2 participants