caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Circular dependencies
@ 2009-07-06  9:27 Pietro Abate
  2009-07-06 10:25 ` [Caml-list] " Johannes Kanig
  0 siblings, 1 reply; 4+ messages in thread
From: Pietro Abate @ 2009-07-06  9:27 UTC (permalink / raw)
  To: caml-list

Hi all,
I've this small compilation problem with ocamlbuild. Basically
private.ml contains the common part of pub1.ml and pub2.ml and out.ml
contains the output type. Here I'm trying to hide private.ml and to 
provide a module algo with only the public interface. If there is a
better way of doing this, I'll be happy to learn. I don't quite get the
circular dependency problem ...

thanks for your help !

Briefly:

#ls
_tags  algo.mlpack  out.ml  private.ml  pub1.ml  pub2.ml

#cat _tags 
<{pub1,pub2,out}.cmx>: for-pack(Algo)

#cat algo.mlpack 
Pub1
Pub2
Out

#cat out.ml      
let b = ()

#cat pub1.ml 
let b = Private.a

#cat pub2.ml 
let b = Private.a

#cat private.ml 
let a = Out.b ;;

Then when I try to compile my library I get : 

#ocamlbuild -classic-display algo.cma
/usr/bin/ocamldep -modules pub1.ml > pub1.ml.depends
/usr/bin/ocamldep -modules private.ml > private.ml.depends
/usr/bin/ocamldep -modules out.ml > out.ml.depends
/usr/bin/ocamlc -c -o out.cmo out.ml
/usr/bin/ocamlc -c -o private.cmo private.ml
/usr/bin/ocamldep -modules pub2.ml > pub2.ml.depends
/usr/bin/ocamlc -c -o pub1.cmo pub1.ml
/usr/bin/ocamlc -c -o pub2.cmo pub2.ml
/usr/bin/ocamlc -pack out.cmo pub1.cmo pub2.cmo -o algo.cmo
Circular dependencies: "algo.cmo" already seen in
  [ "private.cmo"; "algo.cmo" ]
  
as native library :

#ocamlbuild -classic-display algo.cmxa
/usr/bin/ocamlopt -c -for-pack Algo -o out.cmx out.ml
/usr/bin/ocamlopt -c -o private.cmx private.ml
/usr/bin/ocamlopt -c -for-pack Algo -o pub1.cmx pub1.ml
/usr/bin/ocamlopt -c -for-pack Algo -o pub2.cmx pub2.ml
touch algo.mli  ; if  /usr/bin/ocamlopt -pack out.cmx pub1.cmx pub2.cmx
-o algo.cmx  ; then  rm -f algo.mli  ; else  rm -f algo.mli  ; exit 1;
fi
Circular dependencies: "algo.cmx" already seen in
  [ "private.cmx"; "algo.cmx" ]
  

-- 
----
http://en.wikipedia.org/wiki/Posting_style


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

* Re: [Caml-list] Circular dependencies
  2009-07-06  9:27 Circular dependencies Pietro Abate
@ 2009-07-06 10:25 ` Johannes Kanig
  2009-07-06 10:56   ` Pietro Abate
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Kanig @ 2009-07-06 10:25 UTC (permalink / raw)
  To: Pietro Abate; +Cc: caml-list

On Mon, Jul 6, 2009 at 11:27 AM, Pietro
Abate<Pietro.Abate@pps.jussieu.fr> wrote:
> #cat algo.mlpack
> Pub1
> Pub2
> Out

It's a bit confusing, but the mlpack has to contain all the modules of
the pack, and not only the public modules. So you should add "Private"
here. The circular dependency message is ocamlbuild's way of telling
you.

Johannes

-- 
Johannes Kanig
johannes.kanig@lri.fr


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

* Re: [Caml-list] Circular dependencies
  2009-07-06 10:25 ` [Caml-list] " Johannes Kanig
@ 2009-07-06 10:56   ` Pietro Abate
  2009-07-06 11:19     ` Johannes Kanig
  0 siblings, 1 reply; 4+ messages in thread
From: Pietro Abate @ 2009-07-06 10:56 UTC (permalink / raw)
  To: caml-list

On Mon, Jul 06, 2009 at 12:25:58PM +0200, Johannes Kanig wrote:
> Abate<Pietro.Abate@pps.jussieu.fr> wrote:
> > #cat algo.mlpack
> > Pub1
> > Pub2
> > Out
> It's a bit confusing, but the mlpack has to contain all the modules of
> the pack, and not only the public modules. So you should add "Private"
> here. The circular dependency message is ocamlbuild's way of telling
> you.

ok, so if now I want to hide the module private.ml I need to add
algo.mli to hide it . Suppose I've the mli for Pub1 Pub2 and Out .  How
can I easily (without cut and pasting code) create algo.mli ?  Tell me I
do not have to manually add the signature of Pub1 Pub2 and Out ...
searching the list I've got a bad feeling ... Is this the best way to
hide a module ? 

thanks again.
p

-- 
----
http://en.wikipedia.org/wiki/Posting_style


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

* Re: [Caml-list] Circular dependencies
  2009-07-06 10:56   ` Pietro Abate
@ 2009-07-06 11:19     ` Johannes Kanig
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Kanig @ 2009-07-06 11:19 UTC (permalink / raw)
  To: caml-list

On Mon, Jul 6, 2009 at 12:56 PM, Pietro
Abate<Pietro.Abate@pps.jussieu.fr> wrote:
> ok, so if now I want to hide the module private.ml I need to add
> algo.mli to hide it . Suppose I've the mli for Pub1 Pub2 and Out .  How
> can I easily (without cut and pasting code) create algo.mli ?  Tell me I
> do not have to manually add the signature of Pub1 Pub2 and Out ...
> searching the list I've got a bad feeling ... Is this the best way to
> hide a module ?

I don't know of a solution without changing your code. You could
either remove your internal .mli files and put all the interfaces into
algo.mli. Or you create a file signatures.mli which contains the
relevant signatures. In pub1.mli, you could then write include
Signatures.Pub1, and so on, and similarly for algo.mli.

Johannes

-- 
Johannes Kanig
johannes.kanig@lri.fr


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

end of thread, other threads:[~2009-07-06 11:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-06  9:27 Circular dependencies Pietro Abate
2009-07-06 10:25 ` [Caml-list] " Johannes Kanig
2009-07-06 10:56   ` Pietro Abate
2009-07-06 11:19     ` Johannes Kanig

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