Closed leamingrad closed 6 years ago
I'm not a huge fan of ppx_variants_conv
- in particular, I can't work out if there is a better way to generate the list of variants without duplicating the list.
is there by any chance a way to only derive this
Variants.fold
function ?
I haven't been able to find one. I guess the way to do it would be to extract the relevant pre-processor code from ppx_variants_conv
and including it in the package. I'm not hugely keen on that as it doesn't seem like a great fit for this codebase.
I think the "correct" solution here would probably be to create a new ppx_*
package that is a tightened up version of ppx_variants_conv
that is more tuned to the needs of types that are basically just a load of nullary constructors with a a couple of special cases (or even just for all-nullary classes). Then we can swap that in here. Thats probably something for another time though.
Agreed, it's already a good improvement as it is!
This PR enhances
p11_mechanism_type
in a couple of ways:ppx_variants_conv
to generating the list of all elements of the type. This will cause a compiler warning if new elements are added and omitted from the list