Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Chris King <colanderman@g...>
Subject: Re: [Caml-list] Nesting Modules
On 11/1/05, Tom Hawkins <tom@confluent.org> 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 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.

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

ocamlc -pack top.ml bottom.ml 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