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=0.0 required=5.0 tests=none 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 A54BBBC6B for ; Thu, 8 Mar 2007 20:14:28 +0100 (CET) Received: from chokecherry.srv.cs.cmu.edu (CHOKECHERRY.SRV.CS.CMU.EDU [128.2.185.41]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l28JEQQk022110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 8 Mar 2007 20:14:28 +0100 Received: from stratocaster.home (c-24-3-154-106.hsd1.pa.comcast.net [24.3.154.106]) (authenticated bits=0) by chokecherry.srv.cs.cmu.edu (8.13.6/8.13.6) with ESMTP id l28JEPlv026332 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Thu, 8 Mar 2007 14:14:26 -0500 (EST) Received: from ecc by stratocaster.home with local (Exim 4.63) (envelope-from ) id 1HPO4H-0000zB-Kk; Thu, 08 Mar 2007 14:14:25 -0500 Date: Thu, 8 Mar 2007 14:14:25 -0500 To: caml-list@yquem.inria.fr, OCaml Subject: Re: [Caml-list] Labels and polymorphism Message-ID: <20070308191425.GA3724@localhost> Mail-Followup-To: caml-list@yquem.inria.fr, OCaml References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) From: Eric Cooper X-Miltered: at discorde with ID 45F06092.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; polymorphism:01 val:01 ocaml:01 subsection:01 arity:01 arity:01 val:01 int-:01 wrote:01 caml-list:01 matched:01 int:01 int:01 parameters:02 parameters:02 On Thu, Mar 08, 2007 at 10:31:46AM -0800, Nathaniel Gray wrote: > # let f ~x = x;; > val f : x:'a -> 'a = > # f ~x:1;; > - : int = 1 > # f 1;; > - : x:(int -> 'a) -> 'a = > > Can somebody make sense of this for me? Is there a paper somewhere on > labels in ocaml that I should read? Section 6.7.1 of the manual, subsection "Function application", says: As a special case, if the function has a known arity, all the arguments are unlabeled, and their number matches the number of non-optional parameters, then labels are ignored and non-optional parameters are matched in their definition order. The problem is that if the result type of a function f is 'a, then it's not of known arity -- an application of f could produce a function, which could then be applied to more arguments. For example: # let id x = x;; val id : 'a -> 'a = # id id id id 17;; - : int = 17 In your example, if you constrain the type of f, it works as expected: # (f : x:int->int) 1;; - : int = 1 -- Eric Cooper e c c @ c m u . e d u