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 5C255BB84 for ; Sun, 13 Jul 2008 19:39:09 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao0BAAvbeUjOvjGtfGdsb2JhbACSLQEBCwUCBgcRA5UE X-IronPort-AV: E=Sophos;i="4.30,354,1212357600"; d="scan'208";a="15076501" Received: from web54603.mail.re2.yahoo.com ([206.190.49.173]) by mail3-smtp-sop.national.inria.fr with SMTP; 13 Jul 2008 19:39:08 +0200 Received: (qmail 69174 invoked by uid 60001); 13 Jul 2008 17:39:07 -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=zCCCeyCBN7nc2keJfyzJdwZ/1okqyIGsoOcdLZN/QuZiJTHruYjcp5/McwI/ChWGnyReh3Cex/jG0Rra5d726yBl0gGwaAEWRUyd2248KEeXsm8Mjy502IUSyDR6wNtqiVPk0tRCGzi1Yz1CAAfk1YE9NZN73faSMT4qEwe5sBg=; Received: from [212.13.62.166] by web54603.mail.re2.yahoo.com via HTTP; Sun, 13 Jul 2008 10:39:07 PDT X-Mailer: YahooMailWebService/0.7.199 Date: Sun, 13 Jul 2008 10:39:07 -0700 (PDT) From: Dario Teixeira Subject: Re: [Caml-list] Troublesome nodes To: caml-list@yquem.inria.fr In-Reply-To: <220702.43610.qm@web54604.mail.re2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID: <762868.68576.qm@web54603.mail.re2.yahoo.com> X-Spam: no; 0.00; nodes:01 foo:01 foo:01 node:01 node:01 intersection:01 sig:01 val:01 val:01 struct:01 seq:01 seq:01 show-stopper:01 nodes:01 bypassing:01 Hi again, Sorry, but in the meantime I came across two problems with the supposedly ultimate solution I just posted. I have a correction for one, but not for the other. The following statements trigger the first problem: let foo1 =3D text "foo" let foo2 =3D see "ref" let foo3 =3D bold [foo1; foo2] Error: This expression has type Node.link_node_t but is here used with type Node.nonlink_node_t These two variant types have no intersection The solution that immediately comes to mind is to make the return types for the constructor functions open: (I can see no disadvantage with this solution; please tell me if you find any) module rec Node: sig type nonlink_node_t =3D [ `Text of string | `Bold of Node.super_node_t = list ] type link_node_t =3D [ `See of string | `Mref of string * nonlink_node_= t list ] type super_node_t =3D [ nonlink_node_t | link_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 struct type nonlink_node_t =3D [ `Text of string | `Bold of Node.super_node_t = list ] type link_node_t =3D [ `See of string | `Mref of string * nonlink_node_= t list ] type super_node_t =3D [ nonlink_node_t | link_node_t ] let text txt =3D `Text txt let bold seq =3D `Bold (seq :> super_node_t list) let see ref =3D `See ref let mref ref seq =3D `Mref (ref, seq) end The second problem, while not a show-stopper, may open a hole for misuse of the module, so I would rather get it fixed. Basically, while the module provides constructor functions to build nodes, nothing prevents the user from bypassing them and constructing nodes manually. The obvious solution of declaring the types "private" results in an "This fixed type has no row variable" error. Any way around it? Thanks once more for your time, 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