Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] module types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Julien Signoles <Julien.Signoles@l...>
Subject: Re: [Caml-list] module types
> module type T = sig type 'a t end
> module F(M: T): sig
> 	type a
> 	type t = a M.t
> 	(* plus a lot of values... *)
> end = struct
> 	type a = unit
> 	type t = unit M.t
> end
>
> I would like to re-write it like this :
>
> module type T = sig type 'a t end
> module type O =
> sig
> 	type a
> 	type t
> 	(* plus a lot of values... *)
> end
> module F(M: T): O with type t = a M.t =
> struct
> 	type a = unit
> 	type t = unit M.t
> end
>
> but I can't, because "a" is unknown...
> (of course, I want to keep it abstract)
>
> any idea ?

I already encountered this problem a while ago. I solved it by using the
following technic:

module type T = sig type 'a t end
module type O = sig type a type t end
type b = unit
module F(M:T): O with type t = b M.t and type a = b =
struct
  type a = unit
  type t = unit M.t
end

In the signature of the above structure, [b] should be abstract in order
to keep [a] abstract. Sadly, this technic introduces a new type definition
but I don't see a better way to solve this problem.

Hope this helps,
Julien Signoles
-- 
mailto:Julien.Signoles@lri.fr ; http://www.lri.fr/~signoles
"In theory, practice and theory are the same,
but in practice they are different" (Larry McVoy)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners