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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id BB6BCBB84 for ; Thu, 19 Jun 2008 23:59:04 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApUBANFyWkjAXQImiGdsb2JhbACBW5BxAQEBDyCdYQ X-IronPort-AV: E=Sophos;i="4.27,674,1204498800"; d="scan'208";a="14269277" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 19 Jun 2008 23:59:04 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m5JLx1M9002138 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 19 Jun 2008 23:59:04 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArQAAMBzWkhTkhUHmmdsb2JhbACBW5BxAQEBAQEIBQgHEZ1l X-IronPort-AV: E=Sophos;i="4.27,674,1204498800"; d="scan'208";a="14133004" Received: from smtp.dslgb.com (HELO cht-smtp-001.bulldogdsl.com) ([83.146.21.7]) by mail1-smtp-roc.national.inria.fr with ESMTP; 19 Jun 2008 23:59:03 +0200 Received: by cht-smtp-001.bulldogdsl.com (Postfix, from userid 1011) id 694234E5AE8; Thu, 19 Jun 2008 22:59:03 +0100 (BST) Received: from [192.168.123.191] (host-84-9-233-143.dslgb.com [84.9.233.143]) by cht-smtp-001.bulldogdsl.com (Postfix) with ESMTP id A6CAB4E58F8; Thu, 19 Jun 2008 22:58:59 +0100 (BST) Message-ID: <485AD6A3.7060606@ed.ac.uk> Date: Thu, 19 Jun 2008 22:58:59 +0100 From: Jeremy Yallop User-Agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509) MIME-Version: 1.0 To: Jake Donham Cc: caml users Subject: Re: [Caml-list] surprising type error with labels References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 485AD6A5.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; listlabels:01 listlabels:01 bool:01 bool:01 4.1:98 wrote:01 caml-list:01 functions:01 surprising:01 int:01 omitted:01 expression:02 variables:02 labels:03 labels:03 Jake Donham wrote: > Why does > > ListLabels.find (fun _ -> true) [];; > > produce > > Characters 16-31: > ListLabels.find (fun _ -> true) [];; > ^^^^^^^^^^^^^^^ > This expression should not be a function, the expected type is > ('a -> 'b) list > > I thought the rule was that "if an application is total, labels may be > omitted." (4.1 in the manual). (I was trying to do module List = > ListLabels at the top of a file.) Thanks, Applications of functions whose return types are type variables are never considered total, since it's possible to pass extra arguments if the type variable is instantiated to a function type. For example, ListLabels.find has type f:('a -> bool) -> 'a list -> 'a If the type variable is instantiated to `bool -> bool', say, then you can pass more than two arguments: ListLabels.find ~f:(fun f -> f false) [not] false You can use the function without labels if you fix its return type: (ListLabels.find : f:_ -> _ -> int) (fun _ -> true) [] Jeremy.