Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Nesting Modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-02 (02:03)
From: Chris King <colanderman@g...>
Subject: Re: [Caml-list] Nesting Modules
On 11/1/05, Tom Hawkins <> wrote:
> Is it possible to nest modules defined in separate files?

One way to do what you're looking to do, is to write in

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.

A similar effect can be obtained with the -pack flag:

ocamlc -pack foo.cmo

Top and Bottom can now be referenced as Foo.Top and Foo.Bottom, and
only foo.cmo needs to be linked.  I know this isn't exactly what
you're looking for, but it might do the trick just the same.

- Chris King