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
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-20 (17:44)
From: Jacques Le Normand <rathereasy@g...>
Subject: obj.magic for polymorphic record fields
Dear ocaml-list,
the following code does not type check:

type foo = {bar : 'a. 'a -> 'a}
let a : int -> int = fun x -> x
let baz = {bar = Obj.magic a}

with the error

Error: This field value has type 'a -> 'a which is less general than
         'b. 'b -> 'b

my question is: how could I use obj.magic to get a polymorphic type?