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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id DAFF8BBAF for ; Sat, 12 Jul 2008 14:37:16 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqYAANRBeEjOvjGtfGdsb2JhbACSLAEBCwUCBgcRA5Y5 X-IronPort-AV: E=Sophos;i="4.30,349,1212357600"; d="scan'208";a="15033828" Received: from web54603.mail.re2.yahoo.com ([206.190.49.173]) by mail1-smtp-roc.national.inria.fr with SMTP; 12 Jul 2008 14:37:16 +0200 Received: (qmail 75211 invoked by uid 60001); 12 Jul 2008 12:37:15 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=oN9m0AMDvBqmwqo6zU+WM905KiKLolyWeDUA6FaSiyWz8EFdzR6H4Y1dl4butD9FAIp2c9AnB8UdabvtGQUxn98W4UtH0gCQ/yaUn9paOqYx4MdXOl8x+cSVfSxkIhFbo+61vjWSgBQJdGRV47SQ2jlSp05mawFBSB4LXO0Tero=; Received: from [212.13.62.205] by web54603.mail.re2.yahoo.com via HTTP; Sat, 12 Jul 2008 05:37:14 PDT X-Mailer: YahooMailWebService/0.7.199 Date: Sat, 12 Jul 2008 05:37:14 -0700 (PDT) From: Dario Teixeira Subject: Re: [Caml-list] Troublesome nodes To: Jeremy Yallop Cc: caml-list@yquem.inria.fr In-Reply-To: <4877CE91.6010107@ed.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID: <197205.74716.qm@web54603.mail.re2.yahoo.com> X-Spam: no; 0.00; nodes:01 compiler:01 node:01 subset:01 node:01 compiler:01 sig:01 val:01 val:01 struct:01 seq:01 seq:01 foo:01 foo:01 ingenious:98 Hi, Thanks Jeremy, that's quite ingenious. However, I've hit a problem in the definition of the constructor functions (the full code + compiler error is below). Now, I know that nonlink_node_t is a subset of super_node_t, and therefore any variant valid for nonlink_node_t is also acceptable for super_node_t. But how do I tell this to the compiler? (Note that having users of the module manually casting types with :> is something I would rather avoid). Thanks again, Dario module rec Node: sig =09type nonlink_node_t =3D [ `Text of string | `Bold of Node.super_node_t l= ist ] =09type link_node_t =3D [ `See of string | `Mref of string * nonlink_node_t= list ] =09type super_node_t =3D [ nonlink_node_t | link_node_t ] =09val text: string -> nonlink_node_t =09val bold: super_node_t list -> nonlink_node_t =09val see: string -> link_node_t =09val mref: string -> nonlink_node_t list -> link_node_t end =3D struct =09type nonlink_node_t =3D [ `Text of string | `Bold of Node.super_node_t l= ist ] =09type link_node_t =3D [ `See of string | `Mref of string * nonlink_node_t= list ] =09type super_node_t =3D [ nonlink_node_t | link_node_t ] =09let text txt =3D `Text txt =09let bold seq =3D `Bold seq =09let see ref =3D `See ref =09let mref ref seq =3D `Mref (ref, seq) end open Node let foo =3D text "foo" let bar =3D bold [text "bar"] Error: This expression has type Node.nonlink_node_t but is here used with type Node.super_node_t The first variant type does not allow tag(s) `Mref, `See =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