From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id E5A54D45F for ; Wed, 2 Nov 2005 05:06:15 +0100 (CET) Received: from fuzzy.phpwebhosting.com (194.67-19-13.reverse.theplanet.com [67.19.13.194] (may be forged)) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id jA246EPP026998 for ; Wed, 2 Nov 2005 05:06:15 +0100 Received: (qmail 13400 invoked from network); 2 Nov 2005 04:06:08 -0000 Received: from unknown (HELO [192.168.0.4]) (24.163.160.87) by 194.67-19-13.reverse.theplanet.com with (DHE-RSA-AES256-SHA encrypted) SMTP; Tue, 01 Nov 2005 23:06:08 -0500 Message-ID: <436844D6.9000109@confluent.org> Date: Tue, 01 Nov 2005 22:47:18 -0600 From: Tom Hawkins User-Agent: Mozilla Thunderbird 1.0 (X11/20050115) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "William D. Neumann" , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Nesting Modules References: <43679EEF.70102@confluent.org> In-Reply-To: X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43683B36.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 nesting:01 mli:01 mli:01 compiler:01 val:01 val:01 struct:01 sig:01 sig:01 syntax:01 2005,:98 ...:98 ...:98 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 William D. Neumann wrote: > On Tue, 1 Nov 2005, Tom Hawkins wrote: > >> Is it possible to nest modules defined in separate files? >> >> For example, assume I have... >> >> top.ml >> top.mli >> bottom.ml >> bottom.mli >> >> Can I instruct the compiler to nest Bottom somewhere in Top, to obtain >> clean, hierarchical names (eg: Top.Bottom.some_function)? Of course I >> can inline bottom.ml in top.ml, but then the file become rather large. > > > Sort of. You can use include to minimize the file bloat. A stupid > example follows: Thanks William, this helps. One question below... > > ------ > (************************************************************************ * > * bottom.ml > * > ************************************************************************) > > let mname = "Bottom" > > let id x = x ----- > > ----- > (************************************************************************ > * > * bottom.mli > * > ************************************************************************) > > val mname : string > val id : 'a -> 'a > ----- > > ----- > (************************************************************************ > * > * top.ml > * > ************************************************************************) > > let mname = "Top" > > let id x = x > > let double x = x + x > > module Bottom = > struct > include Bottom > end > ----- > > ----- > (************************************************************************ > * > * top.mli > * > ************************************************************************) > > val mname : string > > val id : 'a -> 'a > > val double : int -> int > > module Bottom : sig > val mname : string > val id : 'a -> 'a > end Why repeat Bottom's specification? Why can't we do... module Bottom : sig include Bottom end It appears to be valid syntax, but I get a "Unbound module type Bottom" when I try it. -Tom