From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 9B5ECBBAF for ; Sun, 20 Dec 2009 18:44:58 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgkCAC/xLUtKfU4bkGdsb2JhbACSFIh/PwEBAQEJCQwHEwOnf4EyhAWITwECAwWEKQQ X-IronPort-AV: E=Sophos;i="4.47,428,1257116400"; d="scan'208";a="39079649" Received: from ey-out-2122.google.com ([74.125.78.27]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Dec 2009 18:44:58 +0100 Received: by ey-out-2122.google.com with SMTP id 9so1248032eyd.31 for ; Sun, 20 Dec 2009 09:44:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=n+Wpm1Q/crUzvvBR8MCKeGW3UwOmlyLSgZbD6DQUWlY=; b=LudXQh047lT75xHUWVcpa7YYENebx9Oy4OIiw0WGxMEmNYM60Ge3/ppOMIsbYiNz+8 qcqbbwhAoTh28amQk3I5+OtZy5kXQ98wxilq4X1n4gYMO7BiV+Q0m3UK/7Qa75nPkN+i udgZFg3TE0iejRAjRBn2Nj9vbGUDgPVGCtxQI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=rGngb6+bRJG5H5HIlyHQtEggzsh/Afm4FaiHri3KTByMtF+vganDsvbBAsC4SzNDOE wKJsGVrXVZtOgLIr44cXcTJR1KxnEHGeJpdRo3zLaL8Un1LZjld+V69q4sPj/02kGk76 xZgBVxPK3/oPm9HHwDF6X+tJ8RYWHf3i0PvdI= MIME-Version: 1.0 Received: by 10.216.88.140 with SMTP id a12mr2369489wef.157.1261331097823; Sun, 20 Dec 2009 09:44:57 -0800 (PST) Date: Sun, 20 Dec 2009 12:44:57 -0500 Message-ID: Subject: obj.magic for polymorphic record fields From: Jacques Le Normand To: caml-list caml-list Content-Type: multipart/alternative; boundary=0016e6d7eb4607ab7f047b2c8870 X-Spam: no; 0.00; ocaml-list:01 foo:01 baz:01 ocaml-list:01 foo:01 baz:01 polymorphic:01 polymorphic:01 int:01 int:01 jacques:03 jacques:03 let:03 let:03 fun:08 --0016e6d7eb4607ab7f047b2c8870 Content-Type: text/plain; charset=ISO-8859-1 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? Jacques --0016e6d7eb4607ab7f047b2c8870 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Dear ocaml-list,
the following code does not type check:

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

with the error

Error: Thi= s field value has type 'a -> 'a which is less general than
=
=A0=A0 =A0 =A0 =A0 'b. 'b -> 'b


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


Jacques
--0016e6d7eb4607ab7f047b2c8870--