From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 52EE6BC3F for ; Sat, 30 Oct 2004 03:22:52 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i9U1MpvE006018 for ; Sat, 30 Oct 2004 03:22:52 +0200 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 DAA01074 for ; Sat, 30 Oct 2004 03:22:51 +0200 (MET DST) Received: from mxsrv1.tranzpeer.net (mxsrv1.tranzpeer.net [202.180.66.214]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i9U1Mlcw012854 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 30 Oct 2004 03:22:50 +0200 Received: from [202.180.105.15] (helo=p15.cpich1-n2.callplus.net.nz) by mxsrv1.tranzpeer.net with ASMTP (Exim 4.34) id 1CNhx5-0005BC-El; Sat, 30 Oct 2004 14:22:45 +1300 From: Tony Edgin Reply-To: edgin@slingshot.co.nz Organization: CARP To: Brian Hurt , Ocaml Mailing List Subject: Re: [Caml-list] My wishlist: DRY modules Date: Sat, 30 Oct 2004 14:21:26 +1300 User-Agent: KMail/1.5.3 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200410301421.27004.edgin@slingshot.co.nz> X-Miltered: at concorde with ID 4182ECEB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4182ECE7.003 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wishlist:01 wrote:01 foo:01 foo:01 mli:01 sig:01 val:01 sig:01 val:01 struct:01 struct:01 cheers:01 dry:98 ...:98 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: This is a reply to an old email, but it reflects something I just learned. On Thu, 14 Oct 2004 11:00, Brian Hurt wrote: > I'm doing some work with modules, and I'm learning some of their > annoyances. Number one is having to repeat module type definitions. For > example, say you have a file foo. In foo.mli, you have: > > module type T = sig > type s > val needed : ... > end > > module type S = sig > type t > val doit : ... > val orelse : ... > end > > module Make(Arg: T) : S with type t = Arg.s > > So far, so good, but now in foo.ml you need to replicate the definitions > of *both* T and S: > > module type T = sig > type s > val needed : ... > end > > module type S = sig > type t > val doit : ... > val orelse : ... > end > > module Make(Arg: T) = struct > type t = Arg.s > let doit = ... > let orelse = ... > end One partial solution would be to do the following in your foo.ml file. module type T = Foo.T module type S = Foo.S module Make(Arg: T) = struct type t = Arg.s let doit = ... let orelse = ... end ;; cheers. -- Tony Edgin CARP