Version française
Home     About     Download     Resources     Contact us    
Browse thread
Type constraints
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alain Frisch <Alain.Frisch@i...>
Subject: Re: [Caml-list] Type constraints
Damien Doligez wrote:

> So the answer to your original question is: the type is not generalized
> because in some cases the let-module construct is not safely polymorphic.

Ah ok, this explains that:

# let module M = struct end in fun x -> x;;
- : '_a -> '_a = <fun>

Still, I'm not sure to understand the bottomline. Consider:

# module M = struct let v = ref [] end;;
module M : sig val v : '_a list ref end
# M.v;;
- : '_a list ref = {contents = []}

Here M.v is not generalized either. But here it is:

# module M = struct let v x = x end;;
module M : sig val v : 'a -> 'a end
# M.v;;
- : 'a -> 'a = <fun>

So I don't understand why the same cannot apply to local modules. If the 
let-module-in were declared "safe" for the value restriction, shouldn't

let module M = struct let v = ref [] end in M.v

yield a non-generalized type for the same reason as for the non-local
case (and not because of the value restriction) ?


-- Alain