English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] module / directory tree OR #include for camp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-26 (13:09)
From: Jean-Baptiste Rouquier <jean-baptiste.rouquier@e...>
Subject: [Caml-list] module / directory tree OR #include for camp4
Hello list !
Is there an #include like directive in camlp4 ? I tried #use "foo.ml", 
it works alone, but not in the following case:
    module Bar = struct
    #use "foo.ml"

Here is my problem:
I'd like to structure my code in modules, say I have the modules Plot, 
Topo and Main. Both modules Plot and Topo contain (among others) a 
submodule named Line, so in the module Main I have calls to 
Plot.Line.foo and to Topo.Line.bar. No problems.
But now, since the modules are quite big, I'd like to put them into 
separate directories: sources/topo/<lots of files> and 
sources/plot/<lots of files>. And I'd like to have the submodules Line 
in their own files : sources/topo/line.ml and sources/plot/line.ml. 
Everything compiles fine with the -pack option. But I don't know how to 
generate documentation, since I have no plot.ml or topo.ml files. And 
passing -I plot -I topo makes ocamldoc complain about several 
definitions of module Line.

I tried creating a file sources/plot.ml with
    module Line = struct include Line_aux end
and passing only '-I plot' when compiling (without linking) plot.ml. It 
works, but I can't generate documentation.
I then thought of (file plot.ml)
    module Line = struct
    #use "plot/line.ml"
but it's not accepted by camlp4.

So my question is: Is there a canonical way to have submodules with the 
same name (in different modules) in separate files, allowing to generate 
documentation and use ocamlopt ? It would be even better if the 
directory tree would be reflected in the module tree.

I know I could rename my modules Plot.Line_plot and Topo.Line_topo, but 
it's not satisfying.

To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners