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.1 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 E2BCABC69 for ; Thu, 8 Mar 2007 19:31:48 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l28IVmN3014633 for ; Thu, 8 Mar 2007 19:31:48 +0100 Received: by ug-out-1314.google.com with SMTP id k3so1005069ugf for ; Thu, 08 Mar 2007 10:31:47 -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:mime-version:content-type:content-transfer-encoding:content-disposition; b=E51Z0tq1dNRrQwHyMIx7RE0gMqrftr+AUQbi60xJmEpSUxFr+9ByqVVkMIzMeHy6jVbF0bgkL/VEh3j6o32Dy0l0C8YN93Ri7rmWIbZ0r3K/3BBgY1pxD0sLgNgdlqG7vxA/HZ3ScV521+QA0z1Cef2sr+TaOSqLjDHynR+TcZ4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=dEK2HvnOWjHVU5GopxkHIlQkmrlZNSTx2wZIx63W8jjDkexq2JkO/xQaiF+feqnnPI9V8k5GuJz/3d9lqvXlYtbXWwpDXy8596N4b46+Vgb8QWHrBdLyUz3dFvvnObY86b62p6yL3FXkvb3rGVxJwCf3H5WNKisMo3qvz77FICw= Received: by 10.114.60.19 with SMTP id i19mr255721waa.1173378706371; Thu, 08 Mar 2007 10:31:46 -0800 (PST) Received: by 10.115.54.13 with HTTP; Thu, 8 Mar 2007 10:31:46 -0800 (PST) Message-ID: Date: Thu, 8 Mar 2007 10:31:46 -0800 From: "Nathaniel Gray" To: OCaml Subject: Labels and polymorphism MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 45F05694.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45F05694.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; polymorphism:01 listlabels:01 listlabels:01 val:01 val:01 ocaml:01 partial:01 exception:01 functions:01 functions:01 int:01 int:01 omitted:01 omitted:01 argument:02 I was recently bemoaning the way that folds (especially nested folds) using longish anonymous functions become very hard to read, since the argument order is optimized for greatest opportunity for partial application rather than readability. This led me to think about using ListLabels in my code, but then I hit this bit of documentation: """ As an exception to the above parameter matching rules, if an application is total, labels may be omitted. In practice, most applications are total, so that labels can be omitted in applications. ... But beware that functions like ListLabels.fold_left whose result type is a type variable will never be considered as totally applied. """ Wha?? I'm trying to wrap my head around this but I'm just totally confused. I thought that playing around in the interpreter would help, but it just left me more confused: # let f ~x = x;; val f : x:'a -> 'a = # f ~x:1;; - : int = 1 # f 1;; - : x:(int -> 'a) -> 'a = # let y = f 1;; val y : x:(int -> 'a) -> 'a = # y (fun x -> x+1);; - : x:(int -> (int -> int) -> 'a) -> 'a = Can somebody make sense of this for me? Is there a paper somewhere on labels in ocaml that I should read? Thanks, -n8 -- >>>-- Nathaniel Gray -- Caltech Computer Science ------> >>>-- Mojave Project -- http://mojave.cs.caltech.edu -->