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
module types and constraints in several layers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-15 (13:25)
From: Chris King <colanderman@g...>
Subject: Re: [Caml-list] module types and constraints in several layers
On 3/15/07, Christian Sternagel <christian.sternagel@uibk.ac.at> wrote:
> but I was not able to tell the compiler (correctly) that after
> building module E ist should be the case that for example
> E.E1 = D.D1 = B.B1 = A = E4.D.D1 = E4.D.D2.B1 = ...
> Is there a convenient way to make such a structure of modules?
> And if yes, how ist it done?

What's happening is that, when you specify the type of the results of
B.Make and D.Make, O'Caml throws away the info about how they were
created: since the type signatures B.T and D.T simply say "these
modules have some submodules" but don't say where the submodules come
from, that info becomes hidden (as it should be).  However you can
explicitly instruct the compiler not to hide this info:

module Make (A : A.T) : B.T with module B1 = A = struct
 module B1 = A

This just says "give the resulting module the signature B.T, but
retain the info that module B1 equals A".  Similarly:

module Make (B : B.T) (C : C.T) : D.T
    with module D1 = B.B1 and module D2 = B
    = struct
 module D1 = B.B1
 module D2 = B
 module D3 = C

You don't need to do this with E.Make since its signature is left intact.

You can do this with individual types too, see section 6.10 of the manual.