English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2005-04-01 (02:02)
From: Yaron Minsky <yminsky@g...>
Subject: Another polymorphism puzzle
The last example I posted about had to do with variant types.  Here's
another interseting little typing surprise having to do with record

# 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).