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 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 4709DBC69 for ; Wed, 22 Aug 2007 21:24:50 +0200 (CEST) Received: from bdmail1.accesst.com (pop.bulldoghome.com [83.245.1.230]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7MJOnn6014583 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 22 Aug 2007 21:24:50 +0200 Received: from host-84-9-232-68.bulldogdsl.com ([84.9.232.68] helo=[192.168.123.191]) by bdmail1.accesst.com with esmtpa (Exim 4.50) id 1INvi7-000526-CP; Wed, 22 Aug 2007 20:17:47 +0100 Message-ID: <46CC8D72.50205@ed.ac.uk> Date: Wed, 22 Aug 2007 20:24:34 +0100 From: Jeremy Yallop User-Agent: Mozilla-Thunderbird 2.0.0.4 (X11/20070622) MIME-Version: 1.0 To: Philippe Wang Cc: Yitzhak Mandelbaum , caml-list@yquem.inria.fr Subject: Re: [Caml-list] "opening" record types References: <67ECB685-E69A-43CA-867D-30B879DB0510@research.att.com> <46CC6502.5090003@philippewang.info> In-Reply-To: <46CC6502.5090003@philippewang.info> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46CC8D81.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; struct:01 sig:01 struct:01 wrote:01 caml-list:01 int:01 int:01 expression:02 module:03 module:03 types:05 definition:07 quite:08 useful:09 philippe:11 Philippe Wang wrote: > Instead of : > # module M = struct type t = { a : int ; b : int } end ;; > module M : sig type t = { a : int; b : int; } end > > Write : > # module M = struct type t = { a : int ; b : int } module N = struct > type t = M.t = { a : int ; b : int } end end ;; I don't think this code is quite what you intended. # ({a = 0 ; b = 0 } : M.t );; Characters 1-17: ({a = 0 ; b = 0 } : M.t );; ^^^^^^^^^^^^^^^^ This expression has type t = M.t but is here used with type M.t I like the idea, though. You can avoid duplicating the type definition by writing the inner module first. module M = struct module N = struct type t = { a : int; b : int } end include N end Then, as before: open M.N { a = 0; b = 0 } > That way, when you change or add definitions, it's easy to spread > changes, and you export only what you want to export... Yes. Unforunately, the technique is only useful if you have control of the module that you want to import. Jeremy.