The following blog post might be of use.

   http://ocaml.janestreet.com/?q=node/18

y

On Wed, Dec 17, 2008 at 2:45 PM, Jacques Carette <carette@mcmaster.ca> wrote:
I have two (related) questions:
1) Has anyone transcribed the TypeRep library into ocaml?
http://people.cs.uu.nl/arthurb/dynamic.html

2) How do I embed 'dynamically known' data into a single ocaml data-structure?

More specifically, I am experimenting with a (new) language which allows deduction and computations to be performed with equal ease on its terms.  This language uses ocaml has the host meta-language (ie the interpreter is written in ocaml).  I would like to be able to use arbitrary ocaml data-structures to represent some of my terms, when these terms are known to come from specific theories.  For example, I would like to use Bigint to represent integers, but without exposing that per se.  Perhaps a better way to phrase this would be to say that I want to have a "generic external data container" type in my language terms, which I can instantiate in multiple different ways (in the same program), with data handled in different modules, without having to change the 'generic' data-structure everytime I add a new module.

Polymorphic variants of course come to mind - but they would force me to add a new type parameter to all my types, which I would rather avoid.  I would be quite happy to use polymorphic variants if I could 'hide away' the extra type parameter involved with open variants.  My attempts at hiding this parameter (with existentials) has been too successful, in that once hidden I can't extract my data from this container anymore [which is the correct behaviour for the compiler].

I thought of using objects too, but my data does not really have any common structure, so the object would be a pure container.  I cannot see any advantage over polymorphic variants, and all the same headaches of an 'extra' polymorphic parameter remain.

Jacques



_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs