Hi, > I was going to suggest boxing every node in an ordinary variant type with a > single private constructor: > > type 'a t = private Node of 'a constraint 'a = [< Node.super_node_t ]
Thanks for the suggestion, Jon. Boxing every node is actually very welcome anyway, because later I would like to classify nodes into two different classes, "Basic" and "Complex" (these are orthogonal to the existing link/nonlink distinction), and the only way I see of doing this is via some phantom type trickery (more on that in a later message). Anyway, going back to your boxing suggestion, how can it actually be applied to the signature of the Node module? As you can see below, I have define type 'a t (without the "Node" constructor -- is it really necessary?), but what is the syntax for saying that the constructors text, bold, see, and mref, return a kind of 'a t without breaking the existing restrictions? module rec Node: sig type nonlink_node_t = [ `Text of string | `Bold of Node.super_node_t list ] type link_node_t = [ `See of string | `Mref of string * nonlink_node_t list ] type super_node_t = [ nonlink_node_t | link_node_t ] type 'a t = private 'a constraint 'a = [< super_node_t ] val text: string -> [> nonlink_node_t] val bold: [< super_node_t] list -> [> nonlink_node_t] val see: string -> [> link_node_t] val mref: string -> nonlink_node_t list -> [> link_node_t] end = Sorry for the stream of questions. As you may have noticed, this thread has gone deep into uncharted territory as far as the Ocaml documentation goes. In fact, I have the feeling the only existing documentation for these subjects lies within the collective wisdom of the people on this list... Best regards, Dario Teixeira __________________________________________________________ Not happy with your email address?. Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html _______________________________________________ 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