ocaml-ppx / ppx_tools

Tools for authors of ppx rewriters
MIT License
134 stars 39 forks source link

Compatibility helpers for Ppat_open in Ast_convenience #53

Closed aantron closed 6 years ago

aantron commented 7 years ago

I would be willing to submit PRs for this, but want to discuss first.

Since 4.04 has Ppat_open, and 4.03 and 4.02 do not, would it be reasonable to add two functions to Ast_convenience:

  1. Some kind of higher-order pattern deconstructor, that hides the pattern matching on Parsetree.pattern_desc inside it. The implemention for < 4.04 would simply never call the closure corresponding to Ppat_open.
  2. A wrapper around Ast_helper.Pat.open_. The implementation for < 4.04 would fail at run time. Perhaps we could mark that version with @@ocaml.deprecated to warn about using it.

This kind of thing would help with https://github.com/aantron/bisect_ppx/pull/113, which concerns, in part, pattern matching on patter_desc in 4.04 while preserving compatibility with 4.03 and 4.02.

cc @rleonid

alainfrisch commented 6 years ago

=> ocaml_migrate_parsetree