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
ocamlbuild and automatic dependencies
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-17 (13:52)
From: skaller <skaller@u...>
Subject: Modules for Dummies
On Sat, 2007-03-17 at 09:14 +0100, Alain Frisch wrote:

[changed the title to something more appropriate]

> skaller wrote:
> > So actually, this F is distinct from Foo, even though all the
> > members are the same. In particular, if Foo has an abstract type t,
> > is F.t the same type as Foo.t?
> Yes, because the signature inferred for F keeps a sharing constraint
> t = Foo.t. But if G is some functor with an abstract type s in the
> result, then G(F).s and G(Foo).s are not equal (because there is no
> sharing constraint between modules, such as F = Foo).

Hmm .. this is quite hard to understand.
So let's consider:

module F = Foo
module G = Foo

then F.t and G.t are also the same type because they both
have an inferred sharing constraint t = Foo.t, but F, G,
and Foo are distinct modules. Perhaps I could also write:

module Foo = struct type t = int end
module F = struct type t constraint t = Foo.t val x = 1 end
module G = struct type t constraint t = Foo.t val y = 2 end

to get the same sharing? but clearly Foo, F, G are distinct.

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net