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
Jim Farrand wrote:
> Hi,

> The problem is that the type constraint generated,
> 
> ((fun x -> x) : 'a -> 'a)
> 
> does not reject values with a less general type.  This is fine when the
> type given matches the function, as it does above, but causes me
> problems if the type given is less general.

Maybe you can use local structures and signatures:

(e :: s)  ==>
let module M : sig val v : s end = struct let v = e end in M.v;;

where s is a type scheme.

Btw, does someone know why in

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

the type variable is not generalized ?


-- Alain