I have a problem with the creation of a collection containing heterogeneous elements, in particular element will be structured as follows:
(a,1), ((a,1),1)), ((a,1),1),1) and so on….
can I do this using the module Set of ocaml?
moreover is there also some function that allows me to make the Cartesian product between sets (also heterogeneous ) ?
You cannot build sets of heterogeneous elements. Of course you can define a type to unify the types if you know them in advance. It looks like you do, and it may be the recursive type defined by:
Thus, your examples would constructed as,
Then you would just build the Ordered module to encompass the compare function.
In the case of creating the Cartesian product, you wouldn’t be dealing with heterogeneous elements at this point, but a tuple of the previous type. This would require a new Ordered module to deal with those compares.