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:
> Yes, well I simplified it a bit too much.  Try this instead:
> 
>   let module M = struct let v = ref [] end in M.v;;

I still don't understand. Compare:

# module M = struct let v = ref [] end;;
module M : sig val v : '_a list ref end
# module M : sig val v : 'a -> 'a end = struct let v x = x end;;
module M : sig val v : 'a -> 'a end

Of course, the type variable in the first example must not be 
generalized, and it isn't. In the second example, there is no problem. 
We get:

# M.v;;
- : 'a -> 'a = <fun>

So why not give the same type scheme to:

let module M : sig val v : 'a -> 'a end = struct let v x = x end in M.v

?


Alain