Add Ppx_deriving.register_external #126
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new function allowing one to declare a deriver that is interpret by another ppx rewriter:
The aim is to allow
ppx_deriver
andppx_type_conv
to live in harmony when linked as part of the sameocaml-migrate-parsetree
driver once #123 is merged.Current situation
Currently
ppx_type_conv
does the following in order to interoperate withppx_deriving
:Ppx_deriving
APIppx_deriving
derivers usingPpx_deriving.{add_register_hook,derivers}
If
ppx_deriving
andppx_type_conv
were linked as part of the same omp driver, the result might not be what one would expect. In practice, sinceppx_type_conv
uses the 4.03 AST andppx_deriving
(with #123) uses the 4.05 one,ppx_type_conv
would be executed first and because it removes[@@deriving ...]
annotations,ppx_deriving
would see nothing. This would be a bit surprising for users since as soon as they start using appx_type_conv
based rewriter such asppx_sexp_conv
, they would have to change the option syntax of their[@@deriving ...]
annotations. Moreover it is a bit fragile.Goal
With this PR and #123,
ppx_type_conv
will register its own deriviers withPpx_deriving.register_external
and ignoreppx_deriving
's derivers.This is better than the current situation for two reasons:
ppx_type_conv
andppx_deriving
don't work exactly the same way and with this change they'll both get to interpret their own derivers in the way they were supposed to be interpretedppx_type_conv
is big and tedious and this change will allow us to eventually get rid of it