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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id F1649BC37 for ; Tue, 27 Oct 2009 20:02:24 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqIBAEvg5krRVdvWkGdsb2JhbACRYYkePwEBAQEJCQwHEwOtCoE7hnGIaAEDAwWEOgQ X-IronPort-AV: E=Sophos;i="4.44,634,1249250400"; d="scan'208";a="39054450" Received: from mail-ew0-f214.google.com ([209.85.219.214]) by mail1-smtp-roc.national.inria.fr with ESMTP; 27 Oct 2009 20:02:24 +0100 Received: by ewy10 with SMTP id 10so26750ewy.9 for ; Tue, 27 Oct 2009 12:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=u18xB13pqPyBfi7tg62jXOHfabYqdrC5S5aymn+hd9Y=; b=L1rSThte5CHge1/ZCH6QFddn2u6d5zl03KB10qx0EPrnGvk/1nV22yEFjNW7zuO4MY 03ZZfKhldZE9f2Df70ESr0RkMErR2oj+NRkNoG9u1R0W+XwI12au17oMjBxMBN/TaWsU 5Ap/0CKsXdF7bs4aI89GRdHdRYrTYRYUDsSUg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=AniPt1Uqkb2IRPHclYjEo9/lAt0d+XgbLlDI/Rh35a5OL5caLxcE0WWoj0D4mWDTtu ySgNX8PS5Xr/DTkqmXLIwUj2vuwXEOIlUeL4dlIOvo2fBGoGdgHtk1VDiMb6SSUvip2S Vg2lc7lGrvT1241qhipLoZt5wmbdpkJBXYOxk= Received: by 10.210.2.19 with SMTP id 19mr3568771ebb.94.1256670144230; Tue, 27 Oct 2009 12:02:24 -0700 (PDT) Received: from ?192.168.0.11? (tui75-1-81-57-73-233.fbx.proxad.net [81.57.73.233]) by mx.google.com with ESMTPS id 24sm773341eyx.21.2009.10.27.12.02.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 27 Oct 2009 12:02:23 -0700 (PDT) Message-Id: <890A6948-ACA0-440B-B7B6-EB975C36B596@gmail.com> From: Vincent Aravantinos To: Jake Donham , Marc de Falco , Gurus Ocaml In-Reply-To: <3EEE3582-26E5-40D9-AA3A-C33CF1B4FE50@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: [Caml-list] A strange typing error with polymorphic variants Date: Tue, 27 Oct 2009 20:02:20 +0100 References: <3EEE3582-26E5-40D9-AA3A-C33CF1B4FE50@gmail.com> X-Mailer: Apple Mail (2.936) X-Spam: no; 0.00; variants:01 mutable:01 sqrt:01 bindings:01 -dlambda:01 sqrt:01 inlined:01 2009:98 2.0:98 2.0:98 polymorphic:01 wrote:01 typing:01 caml-list:01 computation:01 Oops, I pushed "send" button too early. Le 27 oct. 09 =E0 19:38, Vincent Aravantinos a =E9crit : > Le 27 oct. 09 =E0 19:24, Jake Donham a =E9crit : > >> On Tue, Oct 27, 2009 at 3:28 AM, Marc de Falco =20 >> wrote: >>> The following code : >>> type 'a p =3D R of 'a t | E of float >>> and 'a t =3D { mutable p : 'a p; c : 'a } >>> let f =3D >>> let x =3D sqrt(2.0) in >>> fun () -> { c =3D `A; p =3D E 0.0 } >>> >>> generates the error : >>> The type of this expression, unit -> _[> `A ] t, >>> contains type variables that cannot be generalized >>> >>> but if I change the x definition to "let x =3D 2.0 in" then it = works. >> >> I think this is just the value restriction. The type of f is >> generalized only if the right hand side is a value (rather than an >> expression needing some computation); in your examples the one that >> fails is not a value, the others are. It looks like there is a >> relaxation to allow let bindings which are themselves values. > > With the -dlambda option, the "sqrt(2.0)" version gives: > (let > (f/92 > (let (x/93 (caml_sqrt_float 2.0)) > (function param/94 (makemutable 0 [1: 0.0] 65a)))) > > whereas the "2.0" version gives: > (let (f/96 (let (x/97 2.0) (function param/98 (makemutable 0 [1: =20 > 0.0] 65a)))) > > i.e. this last version is inlined. Do you think this can give a hint? V.=