caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] module / directory tree  OR  #include for camp4
@ 2004-04-26 13:10 Jean-Baptiste Rouquier
  2004-04-27 18:11 ` Richard Jones
  2004-04-30  0:13 ` Sylvain LE GALL
  0 siblings, 2 replies; 5+ messages in thread
From: Jean-Baptiste Rouquier @ 2004-04-26 13:10 UTC (permalink / raw)
  To: caml-list

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"
    end
.

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"
    end
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.
Thanks,
Jean-Baptiste.

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] module / directory tree  OR  #include for camp4
  2004-04-26 13:10 [Caml-list] module / directory tree OR #include for camp4 Jean-Baptiste Rouquier
@ 2004-04-27 18:11 ` Richard Jones
  2004-04-27 19:13   ` David Brown
  2004-04-27 21:53   ` Jean-Baptiste Rouquier
  2004-04-30  0:13 ` Sylvain LE GALL
  1 sibling, 2 replies; 5+ messages in thread
From: Richard Jones @ 2004-04-27 18:11 UTC (permalink / raw)
  To: Jean-Baptiste Rouquier; +Cc: caml-list

On Mon, Apr 26, 2004 at 03:10:27PM +0200, Jean-Baptiste Rouquier wrote:
> 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.

A pretty hideous solution would be to use a Makefile to concatenate
source files together, eg:

plot.ml: part1.frag part2.frag part3.frag
	cat $^ > $@

Then edit the individual fragments ...

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
Perl4Caml lets you use any Perl library in your type-safe Objective
CAML programs. http://www.merjis.com/developers/perl4caml/

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] module / directory tree  OR  #include for camp4
  2004-04-27 18:11 ` Richard Jones
@ 2004-04-27 19:13   ` David Brown
  2004-04-27 21:53   ` Jean-Baptiste Rouquier
  1 sibling, 0 replies; 5+ messages in thread
From: David Brown @ 2004-04-27 19:13 UTC (permalink / raw)
  To: Richard Jones; +Cc: Jean-Baptiste Rouquier, caml-list

On Tue, Apr 27, 2004 at 07:11:39PM +0100, Richard Jones wrote:

> On Mon, Apr 26, 2004 at 03:10:27PM +0200, Jean-Baptiste Rouquier wrote:
> > 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 have suggested one possible implementation of this feature.  As far as
I can tell, my suggestion has just been ignored.

Dave

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] module / directory tree  OR  #include for camp4
  2004-04-27 18:11 ` Richard Jones
  2004-04-27 19:13   ` David Brown
@ 2004-04-27 21:53   ` Jean-Baptiste Rouquier
  1 sibling, 0 replies; 5+ messages in thread
From: Jean-Baptiste Rouquier @ 2004-04-27 21:53 UTC (permalink / raw)
  To: caml-list


>A pretty hideous solution would be to use a Makefile to concatenate
>source files together, eg:
>
>plot.ml: part1.frag part2.frag part3.frag
>	cat $^ > $@
>
>Then edit the individual fragments ...
>  
>
Yes. But this would imply that line.ml (or part1.frag) is
    module Line = struct
    ...
    end
which is against the file <-> module correspondence (compiling line.ml 
would produce a module Line.Line).

I think I will have a small file plot.ml like
    module Line : sig #include "plot/line.mli" end = struct #include 
"plot/line.ml" end
    module Bar ...
with a small preprocessor providing an #include directive. So I will 
keep the plot/*  files compilable with -pack.
Hoping better module/file tree will be provided in future releases!
Thanks,

-- 
Jean-Baptiste Rouquier
http://perso.ens-lyon.fr/jean-baptiste.rouquier


-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] module / directory tree  OR  #include for camp4
  2004-04-26 13:10 [Caml-list] module / directory tree OR #include for camp4 Jean-Baptiste Rouquier
  2004-04-27 18:11 ` Richard Jones
@ 2004-04-30  0:13 ` Sylvain LE GALL
  1 sibling, 0 replies; 5+ messages in thread
From: Sylvain LE GALL @ 2004-04-30  0:13 UTC (permalink / raw)
  To: Jean-Baptiste Rouquier; +Cc: caml-list

Hello,

On Mon, Apr 26, 2004 at 03:10:27PM +0200, Jean-Baptiste Rouquier wrote:
> Hello list !
> I then thought of (file plot.ml)
>    module Line = struct
>    #use "plot/line.ml"
>    end
> but it's not accepted by camlp4.
o> 

Humm, i read you message very fast, so forgive me if i don't reply to
your question precisely...

I think what you want is :

#cd "plot"
#use "line.ml"
#cd ".."

I think it is working...

Kind regard
Sylvain Le Gall

ps : don't use "plot/line.ml" anyway : "/" is not portable acrosse
filesystem standard.

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-04-30  4:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-26 13:10 [Caml-list] module / directory tree OR #include for camp4 Jean-Baptiste Rouquier
2004-04-27 18:11 ` Richard Jones
2004-04-27 19:13   ` David Brown
2004-04-27 21:53   ` Jean-Baptiste Rouquier
2004-04-30  0:13 ` Sylvain LE GALL

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).