From: Tom Hawkins <tom@confluent.org>
To: "William D. Neumann" <wneumann@cs.unm.edu>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Nesting Modules
Date: Tue, 01 Nov 2005 22:47:18 -0600 [thread overview]
Message-ID: <436844D6.9000109@confluent.org> (raw)
In-Reply-To: <Pine.LNX.4.62.0511011028340.4466@ganymede.cs.unm.edu>
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
next prev parent reply other threads:[~2005-11-02 4:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-01 16:59 Tom Hawkins
2005-11-02 1:39 ` [Caml-list] " Pietro Abate
2005-11-02 6:43 ` Martin Jambon
2005-11-02 1:45 ` Robert Roessler
2005-11-02 2:03 ` Chris King
2005-11-02 8:42 ` Daniel Bünzli
2005-11-02 12:00 ` Tom Hawkins
2005-11-02 12:09 ` Daniel Bünzli
[not found] ` <Pine.LNX.4.62.0511011028340.4466@ganymede.cs.unm.edu>
2005-11-02 4:47 ` Tom Hawkins [this message]
2005-11-02 9:46 ` Richard Jones
2005-11-02 9:57 ` Daniel Bünzli
2005-11-02 10:47 ` Richard Jones
2005-11-02 10:57 ` Daniel Bünzli
2005-11-02 11:27 ` Richard Jones
2005-11-02 11:59 ` Tom Hawkins
2005-11-02 12:33 ` Richard Jones
2005-11-02 13:11 ` Christophe TROESTLER
2005-11-02 14:02 ` Tom Hawkins
2005-11-02 14:36 ` Gerd Stolpmann
2005-11-02 13:34 ` Oliver Bandel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=436844D6.9000109@confluent.org \
--to=tom@confluent.org \
--cc=caml-list@yquem.inria.fr \
--cc=wneumann@cs.unm.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox