ppxlib icon indicating copy to clipboard operation
ppxlib copied to clipboard

What replaced ocaml-migrate-parsetree `Versions.migrate`?

Open mbacarella opened this issue 3 years ago • 2 comments

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!

mbacarella avatar May 13 '22 22:05 mbacarella

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?

pitag-ha avatar May 30 '22 15:05 pitag-ha

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?

mbacarella avatar May 31 '22 01:05 mbacarella