From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA18639; Wed, 24 Mar 2004 11:05:00 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA17832 for ; Wed, 24 Mar 2004 11:04:59 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i2OA5SKW003655 for ; Wed, 24 Mar 2004 11:05:29 +0100 Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2-20030924/3.7W) with ESMTP id TAA20946; Wed, 24 Mar 2004 19:04:44 +0900 (JST) To: Julien.Signoles@lri.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] extensible records again In-Reply-To: References: <20040324104118K.garrigue@kurims.kyoto-u.ac.jp> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20040324190444P.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 24 Mar 2004 19:04:44 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 extensible:01 jacques:01 signoles:01 signoles:01 lri:01 struct:01 functor:01 printf:01 val:01 struct:01 jacques:01 sig:01 sig:01 garrigue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 346 From: Julien Signoles > I think you don't use t0 in Y0 and Ysig because t0 is enclosed > in XY. I would write somethink like: > > (* [...] *) > module Y0(Xrec : Xrec) = struct > module XY = X0(Xrec) > type t = [XY.t | `C] > end > module type Ysig = sig > module XY : Xsig > type t = [ XY.t | `C] > end > module rec Y : (Ysig with module XY = X0(Y)) = Y0(Y) Nicer. I didn't know that you could specify modules inside a signature through functor application. Looks powerful. This allows this even more modular encoding: open Printf module type Xt = sig type t end module type Xrec = sig module T : Xt val show : T.t -> string end module X0t (Xt : Xt) = struct type t = [`A of Xt.t | `B] end module X0(Xrec : Xrec) = struct module T = X0t(Xrec.T) let rec show = function `A x -> "A" ^ Xrec.show x | `B -> "B" end module rec X : (Xrec with module T = X0t(X.T)) = X0(X) module Y0t(Xt : Xt) = struct type t = [X0t(Xt).t | `C] end module Y0(Xrec : Xrec) = struct module T = Y0t(Xrec.T) module XY = X0(Xrec) let rec show = function #XY.T.t as x -> XY.show x | `C -> "C" end module rec Y : (Xrec with module T = Y0t(Y.T)) = Y0(Y) Note of course that this is not very interesting on this simple example. Using that many modules only gets useful if you have several mutually recursive types. Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners