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 ABDE3BBAF for ; Sat, 12 Jul 2008 18:44:49 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj0DAGx8eEiAsLzWYWdsb2JhbACSIhcFCAQUliE X-IronPort-AV: E=Sophos;i="4.30,350,1212357600"; d="scan'208";a="15038121" Received: from zivlnx25.uni-muenster.de ([128.176.188.214]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 Jul 2008 18:44:49 +0200 Received: from [128.176.150.114] (VPNPOOL01-0104.UNI-MUENSTER.DE [128.176.150.114]) by zivlnx25.uni-muenster.de (Postfix) with ESMTP id D58ACB57C7; Sat, 12 Jul 2008 18:44:47 +0200 (CEST) In-Reply-To: <197205.74716.qm@web54603.mail.re2.yahoo.com> References: <197205.74716.qm@web54603.mail.re2.yahoo.com> Mime-Version: 1.0 (Apple Message framework v753.1) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Jeremy Yallop , caml-list@yquem.inria.fr Content-Transfer-Encoding: 7bit From: Wolfgang Lux Subject: Re: [Caml-list] Troublesome nodes Date: Sat, 12 Jul 2008 18:44:49 +0200 To: Dario Teixeira X-Mailer: Apple Mail (2.753.1) X-Spam: no; 0.00; wlux:01 uni-muenster:01 nodes:01 node:01 sig:01 node:01 val:01 val:01 struct:01 seq:01 seq:01 foo:01 foo:01 module's:01 wrote:01 Dario Teixeira wrote: > 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 ] > > 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 = > struct > 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 ] > > let text txt = `Text txt > let bold seq = `Bold seq > let see ref = `See ref > let mref ref seq = `Mref (ref, seq) > end > > open Node > let foo = text "foo" > let bar = 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 This problem is apparently easy to solve. Just don't expect an exact super_node_t list argument for the bold function. Instead use val bold : [< super_node_t] list -> nonlink_node_t in the signature and let bold seq = `Bold (seq :> super_node_t list) in the body of the Node module's definition. Wolfgang