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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id EED30BBAF for ; Fri, 11 Jul 2008 23:20:22 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap8AAOhqd0hTkhUImmdsb2JhbACBWpBOAQEBAQEIBQgHEQOYGA X-IronPort-AV: E=Sophos;i="4.30,347,1212357600"; d="scan'208";a="27251423" Received: from smtp.dslgb.com (HELO cht-smtp-002.bulldogdsl.com) ([83.146.21.8]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Jul 2008 23:20:22 +0200 Received: by cht-smtp-002.bulldogdsl.com (Postfix, from userid 1002) id 7CF201E4489; Fri, 11 Jul 2008 22:20:21 +0100 (BST) Received: from [192.168.123.191] (host-84-9-233-25.dslgb.com [84.9.233.25]) by cht-smtp-002.bulldogdsl.com (Postfix) with ESMTP id 2C9C31E4450; Fri, 11 Jul 2008 22:20:18 +0100 (BST) Message-ID: <4877CE91.6010107@ed.ac.uk> Date: Fri, 11 Jul 2008 22:20:17 +0100 From: Jeremy Yallop User-Agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509) MIME-Version: 1.0 To: Dario Teixeira Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Troublesome nodes References: <845241.60615.qm@web54607.mail.re2.yahoo.com> In-Reply-To: <845241.60615.qm@web54607.mail.re2.yahoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; nodes:01 seq:01 node:01 node:01 seq:01 recursion:01 recursive:01 sig:01 wrote:01 ideally:01 rec:01 caml-list:01 constructor:01 defined:02 string:02 Dario Teixeira wrote: > Ideally, one could do something like this: > > type seq_t = super_node_t list > and nonlink_node_t = > [ `Text of string > | `Bold of seq_t ] > and link_node_t = > [ Mref of string * nonlink_node_t list > | See of string ] > and super_node_t = [nonlink_node_t | link_node_t] > > > However, this fails with an error "The type constructor nonlink_node_t is > not yet completely defined". Here's a slight variation of this scheme that might suit your needs. The idea is to move the recursion from the type level to the module level, sidestepping the restriction that you can't extend types in the same recursive group. module rec M : sig type seq_t = M.super_node_t list type nonlink_node_t = [ `Text of string | `Bold of seq_t ] type link_node_t = [ `Mref of string * nonlink_node_t list | `See of string ] type super_node_t = [ nonlink_node_t | link_node_t ] end = M Jeremy.