cryptosense / pkcs11

OCaml bindings for the PKCS#11 cryptographic API
BSD 2-Clause "Simplified" License
22 stars 6 forks source link

Add a test to check mechanism type variants #106

Closed leamingrad closed 6 years ago

leamingrad commented 6 years ago

This PR enhances p11_mechanism_type in a couple of ways:

leamingrad commented 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.

leamingrad commented 6 years ago

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.

NathanReb commented 6 years ago

Agreed, it's already a good improvement as it is!