From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 465A8BC69 for ; Thu, 8 Mar 2007 20:41:06 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l28Jf5Qq026641 for ; Thu, 8 Mar 2007 20:41:05 +0100 Received: by ug-out-1314.google.com with SMTP id k3so1024773ugf for ; Thu, 08 Mar 2007 11:40:56 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=KjdSYkSwTqU3kLND5CAJ6sOOaFvTd6RHkuUwAf0OVoyH5qTyUDnVB/GG0LCPj2M6vp3FnXj6zrVNnfq5r++vgCxU/H6PoZORoWMe2VwZ3kEwOsW5spvxfSHaHgbOe8GTsbTzi805sLvYiI9nHZboP3EUEa9bZ0aiGRQM2YNdsMQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=tLIKK7yKdchUPQgbFWTkkzkXuInOnJREkwwTJRweOGeHFW03o67h4NjyWpVghOgOXGlvkOwAvIU2jw+4C9Q9lRJ+Qltoz2SPhrw+x59uF0PzOb9UJ26y9GTiTyIZNHjBm2XsU2g5XLCltG6OSADl1AQZ8OogUMlQgR1q6MgKDow= Received: by 10.114.179.1 with SMTP id b1mr266123waf.1173382855032; Thu, 08 Mar 2007 11:40:55 -0800 (PST) Received: by 10.114.131.8 with HTTP; Thu, 8 Mar 2007 11:40:54 -0800 (PST) Message-ID: Date: Thu, 8 Mar 2007 20:40:54 +0100 From: "Roland Zumkeller" To: caml-list@inria.fr Subject: Re: [Caml-list] Labels and polymorphism In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-j-chkmail-Score: MSGID : 45F066D1.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45F066D1.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; polymorphism:01 val:01 ocaml:01 lix:01 wrote:01 partial:01 typing:01 caml-list:01 int:01 int:01 argument:02 argument:02 essentially:02 labels:03 seems:03 On 08/03/07, Nathaniel Gray wrote: > # let f ~x = x;; > val f : x:'a -> 'a = > # f ~x:1;; > - : int = 1 > # f 1;; > - : x:(int -> 'a) -> 'a = The "1" is assumed to be an argument to "f ~x:a" (where "a" is yet to be given). Therefore "f ~x:a" must be of type "int -> ...". Now "f ~x:a" is of the same type as (and here actually reduces to) "a". Hence this type for the x-labeled argument. Perhaps looking at this might help, too: # f 1 1 1;; - : x:(int -> int -> int -> 'a) -> 'a = Now you ask, why are things as they are? Why can't OCaml guess that the "1" was meant for the label "x"? Probably it could, but with such a typing rule we would have to write "(fun ~x:a -> f ~x:a 1)" for what is currently "f 1" (partial application would be essentially lost here). In contrast, becoming able to write "f x" instead of "f ~x:1" seems not enough of a gain to compensate this. Best, Roland -- http://www.lix.polytechnique.fr/~zumkeller/