Version française
Home     About     Download     Resources     Contact us    
Browse thread
annotations and type-checking
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] annotations and type-checking
On Tuesday 28 July 2009 22:47:25 Aaron Bohannon wrote:
> let f (x : 'a) : 'a = x in (f true, f 3);;

Err, good question. :-)

# let f : _ = fun x -> x in f true, f 3;;
- : bool * int = (true, 3)
# let f : 'a = fun x -> x in f true, f 3;;
Error: This expression has type int but is here used with type bool

I'm guessing the scope of the 'a is not what you'd expect but I have no idea 
why. I'd have thought the latter would be a harmless type annotation...

Any takers?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e