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
Re[2]: [Caml-list] obj.magic for polymorphic record fields
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-12-22 (21:49)
From: Boris Yakobowski <boris@y...>
Subject: Re: [Caml-list] obj.magic for polymorphic record fields
On Tue, Dec 22, 2009 at 2:35 PM, Goswin von Brederlow <goswin-v-b@web.de> wrote:
> But the type inference should deduce that in
> (Obj.magic fn) x
> the 'a is actually 'b -> 'c as I am applying an argument to it.

Sure, and it does. But it remains that the principal type of
(Obj.magic fn) is 'a, without any other constraint on 'a. The fact
that you use it with type 'b -> 'c for some 'b and 'c is irrelevant,
and the type-checker can safely draw conclusions from the principal
type. (This is similar to considering List.map (fun x -> x). It has
type 'a list -> 'a list, even though it is used with type int list ->
int list if you apply it to [1].)

Hope this helps,