-
Notifications
You must be signed in to change notification settings - Fork 98
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
optional parameter for ppx_bin_prot #125
Comments
What is the use case for this? I mean, how can a ppx rewriter be present or not? |
My main use case is sharing code between our two apps, one in bucklescript/ReasonML, and the other using native OCaml/dune. Though we use several PPXes in bucklescript, however some we only use in native (ppx_deriving_yojson which already supports optional which made this easy to handle; and ppx_bin_prot) |
I see. That seems like a valid use case to me, thanks for explaining. That is indeed the right place to support |
I can try. Can you give me a rough outline of what you'd want a solution or implementation to look like? |
Sure, so I don't have the code in mind right now and little time to dig in on this subject, so I will only give you high level pointers and will let you do a bit of research for now :) Essentially, at some point we resolve the string "ppx_bin_prot" into a |
This is related to ocaml-ppx/ppx_deriving#247, which really is just this ppxlib issue. if ppxlib's deriving transformation handled the special It would be entirely possible to do this in ppxlib, I just wonder whether this is the most appropriate way to support optional derivers. It kind of hijacks one argument from the derivers' declared argument space. Or given the extremely rare (desired) use of optional derivers, maybe it's fine to not even provide anything for it out of the box, but just require it to be handled on the user's side. I think it would be fairly simple to define a custom in-project deriver that's conditionally just |
ppx_deriving supports an optional flag. From their docs:
This works well for their builtins, but doesn't seem to work for bin_io - which is making writing platform independent code difficult. The bin_io folks suggested that this would need to be implemented here.
Is this the place to support
optional
for all ppx derivers?The text was updated successfully, but these errors were encountered: