caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Yet another question about the module system
@ 1996-10-18  8:41 Jocelyn Serot
  1996-10-21 14:19 ` Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Jocelyn Serot @ 1996-10-18  8:41 UTC (permalink / raw)
  To: caml-list


Hello,

In a previous post i was asking a few questions about the relations between 
the module system and separate compilation. Thanks to the clever answers of
a few people, i thought i have understood the whole stuff. Until i encounter
the following pb:

Suppose i have 2 files:

A first one, specifying an interface for an abstract type Bar:

****** bar.mli **********
type t
val x :t
*************************

A second one, specifying a second abstract type built upon the first one
using functor application

****** foo.mli **********
module type FOO = sig type t val y : t end
module Make(B:Bar) : (FOO with type t = Bar.t)
*************************

Trying to compile this separately:

	> ocamlc -c bar.mli
	> ocamlc -c foo.mli

produces the following error message:
	> File "foo.mli", line 3, characters 14-17: Unbound module type Bar

BUT, if write foo.mli like that

****** foo.mli **********
module type FOO = sig type t val y : t end
val y : Bar.t
*************************

Everythings compiles ok.
So, it seems that the Bar interface is known when compiling Foo (i guess this
goes trough the bar.cmi file).
Why cannot it be used as a functor argument then ?

	Jocelyn Serot

Es-mail: jserot@epcc.ed.ac.uk  (->Nov 29/96) ...............................
S-mail: LASMEA - URA 1793 CNRS, Universite Blaise Pascal, 63177 Aubiere cedex
Tel: (33) 73.40.73.30 - Fax: (33) 73.40.72.62 ...............................
.... http://wwwlasmea.univ-bpclermont.fr/Personnel/Jocelyn.Serot/Welcome.html





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

* Re: Yet another question about the module system
  1996-10-18  8:41 Yet another question about the module system Jocelyn Serot
@ 1996-10-21 14:19 ` Xavier Leroy
  1996-10-21 14:44   ` Jocelyn Serot
  0 siblings, 1 reply; 3+ messages in thread
From: Xavier Leroy @ 1996-10-21 14:19 UTC (permalink / raw)
  To: Jocelyn Serot; +Cc: caml-list


> Suppose i have 2 files:
> 
> A first one, specifying an interface for an abstract type Bar:
> 
> ****** bar.mli **********
> type t
> val x :t
> *************************
> 
> A second one, specifying a second abstract type built upon the first one
> using functor application
> 
> ****** foo.mli **********
> module type FOO = sig type t val y : t end
> module Make(B:Bar) : (FOO with type t = Bar.t)
> *************************
> 
> Trying to compile this separately:
> 
> 	> ocamlc -c bar.mli
> 	> ocamlc -c foo.mli
> 
> produces the following error message:
> 	> File "foo.mli", line 3, characters 14-17: Unbound module type Bar

Having a bar.cmi file around defines a module named "Bar", but not a
module type named "Bar".

You're confusing a module "value" (a module implementation, such as
Bar) with a module type (a module specification, such as the one
expected for the type of the module parameter B).

> So, it seems that the Bar interface is known when compiling Foo (i guess this
> goes trough the bar.cmi file).
> Why cannot it be used as a functor argument then ?

It can be used as a functor argument, as in

        module B = Foo.Make(Bar)

but not as the type of a functor parameter, as in your example.

- Xavier Leroy





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

* Re: Yet another question about the module system
  1996-10-21 14:19 ` Xavier Leroy
@ 1996-10-21 14:44   ` Jocelyn Serot
  0 siblings, 0 replies; 3+ messages in thread
From: Jocelyn Serot @ 1996-10-21 14:44 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: caml-list


Ok, i had my both thoughts cleared (thanks to you) and my pb
solved (thanks to F. Rouaix).
The solution seems to write an explicit module type in the
first file :
******* file bar.ml **********
module type BAR = sig type t val x : t end
******************************
and to refer to this signature in the second file:
******* file foo.mli *********
open Bar
module type FOO = sig type t type p val y : t end
module Make(B:BAR) : (FOO with type t = B.t)
******************************

Thanks for your help.

Oh, and "pendant que j'y suis" as we say in french :-) i have
another question:

Is there a way to tell the ocamlopt native compiler to use a
given C compiler after it has been built and installed ? If not,
what is the configuration option to modify in order to specify
such a C compiler (which may be distinct from the compiler used
for building the caml tools) ?

	Jocelyn Serot

-- 
E-mail: jserot@epcc.ed.ac.uk (->29/11) ......................................
S-mail: LASMEA - URA 1793 CNRS, Universite Blaise Pascal, 63177 Aubiere cedex
Tel: (33) 73.40.73.30 - Fax: (33) 73.40.72.62 ...............................
.... http://wwwlasmea.univ-bpclermont.fr/Personnel/Jocelyn.Serot/Welcome.html





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

end of thread, other threads:[~1996-10-22 14:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-18  8:41 Yet another question about the module system Jocelyn Serot
1996-10-21 14:19 ` Xavier Leroy
1996-10-21 14:44   ` Jocelyn Serot

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