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 3D153D45F for ; Wed, 2 Nov 2005 12:19:34 +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 jA2BJXEM030332 for ; Wed, 2 Nov 2005 12:19:33 +0100 Received: (qmail 26318 invoked from network); 2 Nov 2005 11:19:31 -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; Wed, 02 Nov 2005 06:19:31 -0500 Message-ID: <4368AA69.4090504@confluent.org> Date: Wed, 02 Nov 2005 06:00:41 -0600 From: Tom Hawkins User-Agent: Mozilla Thunderbird 1.0 (X11/20050115) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Nesting Modules References: <43679EEF.70102@confluent.org> <875c7e070511011803x598ffb63gd54267aec1fb181e@mail.gmail.com> 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: 8bit X-Miltered: at nez-perce with ID 4368A0C5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 nesting:01 cmo:01 cmi:01 'let:01 ocamlc:01 ocamlc:01 cmo:01 cmi:01 ocaml:01 cmxa:01 mli:01 'let:01 mli:01 ocaml: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 Daniel Bünzli wrote: > e 2 nov. 05 à 03:03, Chris King a écrit : > >> One way to do what you're looking to do, is to write in top.ml: >> >> module Bottom = Bottom >> >> This will essentially re-export Bottom in Top. Unfortunately, this >> requires that you link bottom.cmo in with your code, which causes >> Bottom to be visible at the top level. > > > It will not be visible to the user if you don't provide bottom.cmi. The > problem of linking can be alleviated by packing everything in a cma > library. In other words what you can do is > > > echo 'let f x = x' > bottom.ml > > echo 'module Bottom = Bottom' > top.ml > > ocamlc -c bottom.ml > > ocamlc -c top.ml > > ocamlc -a -o toplib.cma bottom.cmo top.cmo > > rm bottom.cmi > > ocaml toplib.cma > Objective Caml version 3.09.0 > > # Bottom.f;; > Unbound value Bottom.f > # Top.Bottom.f;; > - : 'a -> 'a = > > When you want to link an executable using Top you now need to specify > toplib.cma (instead of top.cmo). Building a cma/cmxa is fine -- I am working on a library after all. But for this to work, how are the mli files handled? I tried several variations of the following, but again, I'm faced with "Unbound module type Bottom": echo 'let hello = "hello"' > bottom.ml echo 'val hello : string' > bottom.mli echo 'module Bottom = Bottom' > top.ml echo 'module type Bottom = Bottom' > top.mli ocamlc -c bottom.mli ocamlc -c bottom.ml ocamlc -c top.mli File "top.mli", line 1, characters 21-27: Unbound module type Bottom This must be a common problem. Surely I'm not the first person constructing a hierarchical library. OCaml claims to have a hierarchical module system, but I have yet to see an easy way to build a hierarchy of modules. Am I really going to have to revert to a preprocessor?!? -Tom