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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Manos Renieris <er@c...>
Subject: Re: [Caml-list] Another polymorphism puzzle
Worse:

# let f x = { () with foo = 3};;                    
val f : 'a -> int t = <fun>
# let f x = { 42 with foo = 3};; 
val f : 'a -> int t = <fun>

I think this qualifies as a bug. Especially since the documentation
says the expr on the left hand side of with has to be a record.

Thu, Mar 31, 2005 at 09:02:14PM -0500, Yaron Minsky wrote:
> The last example I posted about had to do with variant types.  Here's
> another interseting little typing surprise having to do with record
> types:
> 
> # type 'a t = { foo: 'a };;
> type 'a t = { foo : 'a; }
> # let f x = { x with foo = 3 };;
> val f : 'a -> int t = <fun>
> 
> I can kind of see how this happened, since after all, the result of (f
> x) does not depend in any way on x.  And yet, it seems like the
> unification rules should force f to have time ('a t -> int t).
> 
> y
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs