Creating/using extensions that are not possible to impement with Ppxlib

As part of our code base we have a custom ppx that uses OCaml-migrate-parsetree 1.8.0 (before the ppx driver was removed). We use this ppx to perform nonstandard ppx transformations. These transformations are used to compile a piece of (legacy) code that was ported from other programming language. This ppx is instrumental to make this part of the code readable and still maintainable.

I’m afraid that, with the recent changes in the ppx ecosystem, in a short future it will not be possible for us to keep upgrading OCaml and it’s libraries because we are holding to OCaml-migrate-parsetree 1.8.0 and I see that this dependency is already holding back many other libraries and tools.

As I mentioned before, our ppx performs other AST transformations and optimizations I don’t see a way of doing those within the bounds of Ppxlib. So here’s my question:

What would be your recommendation to maintain our custom syntax extension?

A few things to consider:

  • it needs to work with Dune
  • we only need to support the version of the OCaml compiler we are actively using (no need of OCaml-migrate-parsetree).
  • we need to use other Ppxlib based extension.

My understanding is that you can still perform whole-AST transformations using ppxlib (even if this is a bit less composable and efficient), see ppxlib/driver.mli at 7ba65ff15907720cf9f00366051dd1348384f320 · ocaml-ppx/ppxlib · GitHub.


Thank you very much for the pointer! After reading the Ppxlib manual I was under the impression that it was not possible.