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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id A045EBB84 for ; Fri, 23 May 2008 08:19:03 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArwBALL+NUjAXQIniGdsb2JhbACSNwEBAQ8gnQ4 X-IronPort-AV: E=Sophos;i="4.27,527,1204498800"; d="scan'208";a="12944295" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 23 May 2008 08:19:03 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m4N6J0Ph032193 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 23 May 2008 08:19:03 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al8AAEr+NUjUGyodmmdsb2JhbACSNwEBAQEBCAUIBxEDnQk X-IronPort-AV: E=Sophos;i="4.27,527,1204498800"; d="scan'208";a="11027259" Received: from smtp3-g19.free.fr ([212.27.42.29]) by mail2-smtp-roc.national.inria.fr with ESMTP; 23 May 2008 08:19:02 +0200 Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id 9F80317B547; Fri, 23 May 2008 08:19:02 +0200 (CEST) Received: from [192.168.0.3] (rke75-3-82-229-183-156.fbx.proxad.net [82.229.183.156]) by smtp3-g19.free.fr (Postfix) with ESMTP id 71BB317B545; Fri, 23 May 2008 08:19:02 +0200 (CEST) Message-ID: <483661D2.9040301@frisch.fr> Date: Fri, 23 May 2008 08:18:58 +0200 From: Alain Frisch User-Agent: Thunderbird 3.0a1pre (Windows/2008050403) MIME-Version: 1.0 To: Fabrice Marchant Cc: caml-list Subject: Re: [Caml-list] A functor to produce recursive modules ? References: <20080522225830.52208601@orange.fr> In-Reply-To: <20080522225830.52208601@orange.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 483661D4.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; frisch:01 frisch:01 functor:01 recursive:01 recursive:01 parametrized:01 orderedtype:01 functors:01 functor:01 orderedtype:01 struct:01 sig:01 val:01 val:01 struct:01 Fabrice Marchant wrote: > Hi ! > > Apologize. This topic isnt't exactly at its right place : belongs to Beginners-list. > However no answer about this question there and so much clever people here, a denser traffic... > > Please how to define recursive modules that are parametrized by an OrderedType ? > Say these modules types are Mod and ModSet. > (Because a function f in module Mod uses a Set of Mod) > > The problem is I need recursive functors that returns 2 modules. I'm not sure to understand. Maybe a functor that returns a pair of mutually recursive modules is what you want. module F(X : Set.OrderedType) = struct module rec Mod : sig type t = X of int * ModSet.t val compare: t -> t -> int val of_list: t list -> t end = struct type t = X of int * ModSet.t let compare (X (i, _)) (X (j, _)) = compare i j let of_list i l = X (i, List.fold_right ModSet.add l ModSet.empty) end and ModSet : Set.S with type elt = Mod.t = Set.Make(Mod) end -- Alain