-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add show @printer
support for polymorphic variants
#286
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is a nice thing to have, and the implementation in this PR is slightly better than #267. Let's not make it wait as long...
Could you maybe include a CHANGELOG entry to credit both you and @ghuysmans, so that we don't forget to do so later?
@@ -23,6 +23,7 @@ let attr_printer context = Attribute.declare "deriving.show.printer" context | |||
Ast_pattern.(single_expr_payload __) (fun e -> e) | |||
let ct_attr_printer = attr_printer Attribute.Context.core_type | |||
let constr_attr_printer = attr_printer Attribute.Context.constructor_declaration | |||
let rtag_attr_printer = attr_printer Attribute.Context.rtag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was lost for a while as to what rtag
means. The answer is that this obscure name comes from the parsetree, and it means "a constructor declaration in a polymorphic variant type" (r
means row
and tag
is supposed to suggest constructor
, I guess). The other PR #267 uses attr_printer field.prf_attributes
directly, and I suppose that usig the ppxlib mechanism as in here is better.
34a5bff
to
fc7e50d
Compare
This missing support is listed as one of the motivations for ppx_deriving_variant_string:
I quickly implemented this and only then discovered that #267 already exists.
The difference is that this is for the migrated ppxlib attributes and does use
wrap_printer
.