Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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?