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 52A8CBC37 for ; Tue, 27 Oct 2009 19:38:04 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsQBAKva5kpKfU4ZkGdsb2JhbACRYIkePwEBAQEJCQwHEwOtBoE7hnKIaAEDAwWEOgQ X-IronPort-AV: E=Sophos;i="4.44,634,1249250400"; d="scan'208";a="35703903" Received: from ey-out-2122.google.com ([74.125.78.25]) by mail2-smtp-roc.national.inria.fr with ESMTP; 27 Oct 2009 19:38:04 +0100 Received: by ey-out-2122.google.com with SMTP id 9so25132eyd.7 for ; Tue, 27 Oct 2009 11:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=WLGzHniTcNNkf44ZLal4NmEuCeB4oYF/UtO1QY+R+UU=; b=D2ym/p+BN81neDGocmfMKZHLrHBejMFlpQ4ntqO9pXdACOMUH1V9W3GFmdKD42rxhA uQp8EWIJZopkKNaYhj6P3QTFuAPoDM+FgNxp9FQfw/02wPjWL1NtZCwKOrEHL1lVGknc HUpNdzpgZq2tXzRBN/T+Hgbg3QqdO+n5qitHI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=DvjwKOSZHdGQrIIu7X0ultUpYf8Cr3qBvwo7tEbQsvOT1A15bI8u+GbkpMmi+s4gdZ Ugm3+qZnG+YLW1WFhyX05Fkt1f0b+Kx5ogsjjcOIi+zI81iXJsqpc8drIyeDDqdGfnms F3FAlirH9mR4yWB0OhYNiNNF3fr0TWnIzoEyg= Received: by 10.211.132.20 with SMTP id j20mr5484877ebn.32.1256668683775; Tue, 27 Oct 2009 11:38:03 -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 24sm737380eyx.13.2009.10.27.11.38.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 27 Oct 2009 11:38:02 -0700 (PDT) Cc: Marc de Falco , caml-list@inria.fr Message-Id: <3EEE3582-26E5-40D9-AA3A-C33CF1B4FE50@gmail.com> From: Vincent Aravantinos To: Jake Donham In-Reply-To: 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 19:38:00 +0100 References: 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 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. I thought the yping was done before (??) V.