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
Private modules in packages
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-05-21 (09:51)
From: Hans Ole Rafaelsen <hrafaelsen@g...>
Subject: Re: [Caml-list] Private modules in packages
Thanks Michael and Julien,

That did the trick. I manually inserted the content of the Bar.mli and
Foo.mli into the P.mli file. Guess unless it is some way to include this
automatically the best will be to write a script to generate the P.mli file
automatically based on current version of Bar.mli and Foo.mli as part of the
build process.

Hans Ole

On Fri, May 21, 2010 at 10:53 AM, Julien Signoles <
> wrote:

> Hello,
> 2010/5/21 Hans Ole Rafaelsen <>
> When packing a set of modules into a top module using -pack, is there a way
>> to have some of the modules private to the package?
>> If I have the modules Helper, Foo and Bar. Helper provides helper
>> functions used by Foo and Bar. When I'm packing them into a top mudule P, I
>> do not want to expose the functions of Helper to users of P.
>> Is there some way to achieve this?  If not, do anyone know of other ways
>> for packing libraries and keeping some of the modules private to the
>> library?
> Just write yourself a file p.mli without your private modules:
> === p.mli ===
> module Foo : ...
> module Bar : ...
> ==========
> Of course, you can not refer to signatures of modules Foo and Bar in p.mli.
> Thus you have to duplicate them or, better, to write them somewhere outside
> the package.
> From a compilation point of view, be sure to generate p.cmi by using p.mli
> before generating the pack files[ox].
> We use such a trick in the Frama-C tool ( for providing
> (usually empty) interfaces of its plug-ins. But I do not recommend you to
> read the Frama-C Makefiles for looking at the corresponding compilation
> lines (except if you are **very** motivated).
> Hope this helps,
> Julien