Version française
Home     About     Download     Resources     Contact us    
Browse thread
a module with multiple signatures
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] a module with multiple signatures

Keiko Nakata writes:
 > 
 > I tried to give a module different signatures through an use of functors.
 > Then I faced a situation for which I do not understand the reason.
 > 
 > This is the simplified version of my situation.
 > [...]
 > Anyway,
 > there may be a nicer way to give a module multiple signatures
 > while avoiding duplicate type declarations as possible?
 > (In the above setting, I want to make the type s in M abstract in some 
 > context, but transparent in another context.)

I think you can proceed as follows:

  module M = struct type s type t = A | B end
  module M1 : sig type t = M.t = A | B end = M
  module M2 : ... = M

i.e. you cannot put only "t = M.t" in the signature of M1, you need to
add "=  A|B". This is called  a "re-exported variant  type" in Ocaml's
manual (see http://caml.inria.fr/pub/docs/manual-ocaml/manual018.html)

-- 
Jean-Christophe