I am building two libraries in OCaml which contain the same variant type. The detail of the variant is not too important, other than that it is really large, and it would be annoying to manually write conversion functions for it. (It's actually the bfd_architecture enumeration converted from C using ocamlidl).
I'm now writing a program using the two libraries. In particular, I'm calling A.f which returns a value of A.variant_type, and I need to use that value in a call to B.g, which takes a value of B.variant_type as an input.
Is there any way to tell OCaml that A.variant_type and B.variant_type are really the same type, and thus it's okay to convert a value from one to the other? The libraries are independent, so they should not reference each other. Right now I'm using Obj.magic to do the conversion, but this is a hack.
open
the module to make the naming more lightweight. – Jeffrey Scofield