Programming problems and weird error messages
Can I have two mutually recursive compilation units / structures /
signatures / functors?
No, unfortunately. This would raise serious typing and compilation
problems. Some workarounds are explained in the user manual.
How do I express sharing constraints?
Use manifest type specifications in the arguments of the
functor. For instance, assume defined the following signatures:
module type S1 = sig ... type t ... end
module type S2 = sig ... type u ... end
To define a functor
F that takes two arguments
Y:S2 such that
Y.u share, write:
module F (X: S1) (Y: S2 with type u = X.t) =
struct ... end
Internally, this expands to
module F (X: S1) (Y: sig ... type u = X.t ... end) =
struct ... end
On this form, it is clear that
F can only be applied to
B that meet the
specifications, i.e. such that
B.u is provably equivalent
A.t. Moreover, given the declaration of the functor
Y, the body of the functor can assume that
B.u = A.t. Therefore, this works exactly like a sharing
Compilation units are forced to be structure. What if I want to make
a unit with a functor or a signature instead?
In Objective Caml, functors and signatures (module types) can be
components of structures. So, just make the functor or signature be a
component of a compilation unit. A good example is the module
Set from the standard library.
It is the same type name, but not necessarily the same type.
Two type constructors can have the same name, but
actually represent different types. See the user manual.
this expression has type t but is here used with
type t. I'm confused. Isn't this the same type?
What is this business about type variables that cannot be
The simplest solution to the long-standing problem of polymorphic
references. See the
A more detailed
(in the context of Caml Light 0.7) can be found in the Caml FAQ, and
in the Caml mailing
Objective Caml -
Projet Cristal -
Contact the Caml maintainers
Author: Xavier Leroy --
Last modified: 1999/02/09