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.4 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id A2830BB84 for ; Fri, 23 May 2008 21:53:27 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApwBAD+9NkhQDPKLb2dsb2JhbACBVZBkAQwFAgQHEwOWVoVw X-IronPort-AV: E=Sophos;i="4.27,531,1204498800"; d="scan'208";a="11055948" Received: from smtp2a.orange.fr ([80.12.242.139]) by mail2-smtp-roc.national.inria.fr with ESMTP; 23 May 2008 21:53:27 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2a07.orange.fr (SMTP Server) with ESMTP id 008907000116 for ; Fri, 23 May 2008 21:53:27 +0200 (CEST) Received: from localhost.localdomain (Mix-Lyon-109-1-195.w193-250.abo.wanadoo.fr [193.250.9.195]) by mwinf2a07.orange.fr (SMTP Server) with ESMTP id 1994870000D4 for ; Fri, 23 May 2008 21:53:25 +0200 (CEST) X-ME-UUID: 20080523195326104.1994870000D4@mwinf2a07.orange.fr Date: Fri, 23 May 2008 20:00:04 +0200 From: Fabrice Marchant To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] A functor to produce recursive modules ? Message-ID: <20080523200004.7e7a7827@orange.fr> In-Reply-To: <483661D2.9040301@frisch.fr> References: <20080522225830.52208601@orange.fr> <483661D2.9040301@frisch.fr> X-Mailer: Claws Mail 3.2.0 (GTK+ 2.12.9; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; functor:01 recursive:01 recursive:01 functors:01 functor:01 orderedtype:01 struct:01 sig:01 val:01 val:01 elt:01 struct:01 elt:01 functors:01 rec:01 Thanks a lot Alain ! > > 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. That's it ! > 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 val of_list: int -> ModSet.elt 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 This was the kind of example I needed. Up to now, I don't have written many functors. My problem here was simply I didn't thought to nest the two recursive modules inside a functor. This becomes obvious now. Regards, Fabrice