From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 9C8C0BB84 for ; Mon, 14 Jul 2008 17:11:42 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmEBAGMJe0jOvjGwfGdsb2JhbACSLwEBCwUCBAkRA5gK X-IronPort-AV: E=Sophos;i="4.30,359,1212357600"; d="scan'208";a="15096610" Received: from web54606.mail.re2.yahoo.com ([206.190.49.176]) by mail3-smtp-sop.national.inria.fr with SMTP; 14 Jul 2008 17:11:41 +0200 Received: (qmail 91479 invoked by uid 60001); 14 Jul 2008 15:11:40 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-Mailer:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=OYUQHK84U71czTfWSHyneZ7bg8EabYrb8u1lcwZDRc4W7r7/873vnogTwjJS71zIFuMbe7+a7fjYSal/EamBLF3Yd2KgzbjRk/DyqYtokGzaM2TC4OGeCaPo1zPGqtGn4COiTpjwjVA9XSRc9ZRzPj6eS7ApR57a4VQvaKad9Dw=; Received: from [212.13.63.72] by web54606.mail.re2.yahoo.com via HTTP; Mon, 14 Jul 2008 08:11:40 PDT X-Mailer: YahooMailWebService/0.7.199 Date: Mon, 14 Jul 2008 08:11:40 -0700 (PDT) From: Dario Teixeira Subject: Re: [Caml-list] Troublesome nodes To: caml-list@yquem.inria.fr, Jon Harrop In-Reply-To: <200807132210.55790.jon@ffconsultancy.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID: <790934.91073.qm@web54606.mail.re2.yahoo.com> X-Spam: no; 0.00; nodes:01 node:01 node:01 nodes:01 orthogonal:01 syntax:01 constructors:01 sig:01 val:01 val:01 ocaml:01 rec:01 caml-list:01 constructor:01 constructor:01 Hi, > I was going to suggest boxing every node in an ordinary variant type with= a > single private constructor: >=20 > type 'a t =3D private Node of 'a constraint 'a =3D [< 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 =3D [ `Text of string | `Bold of Node.super_nod= e_t list ] type link_node_t =3D [ `See of string | `Mref of string * nonlink_n= ode_t list ] type super_node_t =3D [ nonlink_node_t | link_node_t ] type 'a t =3D private 'a constraint 'a =3D [< 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 =3D 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 =0A=0A=0A __________________________________________________________= =0ANot happy with your email address?.=0AGet the one you really want - mill= ions of new email addresses available now at Yahoo! http://uk.docs.yahoo.co= m/ymail/new.html