From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id BF9517EE20 for ; Fri, 16 Nov 2012 16:59:02 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of edwin+ml-ocaml@etorok.net) identity=pra; client-ip=176.9.138.55; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="edwin+ml-ocaml@etorok.net"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of edwin+ml-ocaml@etorok.net designates 176.9.138.55 as permitted sender) identity=mailfrom; client-ip=176.9.138.55; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="edwin+ml-ocaml@etorok.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of postmaster@mail.etorok.net designates 176.9.138.55 as permitted sender) identity=helo; client-ip=176.9.138.55; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="edwin+ml-ocaml@etorok.net"; x-sender="postmaster@mail.etorok.net"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuUKAABiplCwCYo3/2dsb2JhbABEgmyDMrs8AQMBA4EEgQiCHgEBBSMECwENAQE2Ag8LGAICBRYLAgIJAwIBAgFFEwgCiAoDqmVwg0cBBY8SBoEiixGBZoIUgROVf5BDgnE X-IronPort-AV: E=Sophos;i="4.83,265,1352070000"; d="scan'208";a="162762813" Received: from mail.etorok.net ([176.9.138.55]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Nov 2012 16:59:02 +0100 Received: from [IPv6:2a02:2f02:1022:a229:1e6f:65ff:fe23:db0d] (unknown [IPv6:2a02:2f02:1022:a229:1e6f:65ff:fe23:db0d]) by mail.etorok.net (Postfix) with ESMTPSA id A14FF46AF for ; Fri, 16 Nov 2012 16:59:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=etorok.net; s=MAILOUT; t=1353081540; bh=KbaY3rdTwF/cKMubZOty46aFdiMDUdZylLyOvnotqww=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=TMeWuEf8vXJlUbfn5a6okfYUQ4JwaxtfY7QpvA3zkEEetsSO1Kf5L/x468voVyeJD zABNPTJV1qXV7gwYQ6N17iddDJXiXuwLgIrC9vORN0nVBt9pCUvr6696jiR53NPixq 8bK7vogqi6b0m3cFPjH02gVNGXof8l2MO8DTpH20= Message-ID: <50A662C2.8000402@etorok.net> Date: Fri, 16 Nov 2012 17:58:58 +0200 From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121027 Icedove/10.0.10 MIME-Version: 1.0 To: caml-list@inria.fr References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.97.6 at mail X-Virus-Status: Clean Subject: Re: [Caml-list] confusing type error when using function with optional arguments On 11/16/2012 04:50 PM, Milan Stanojević wrote: > I was playing with %revapply primitive and ran into the following > compiler behavior that I don't understand. > > external (|!) : 'a -> ('a -> 'b) -> 'b = "%revapply" > > let foo1 ?x ?y () = () (* val foo1 : ?x:'a -> ?y:'b -> unit -> unit > *) > let foo2 ?x ?y z = z (* val foo2 : ?x:'a -> ?y:'b -> 'c -> 'c *) > > let x = () |! foo1 (* compiles just fine *) > > let y = () |! foo2 (* fails with > Error: This expression has type ?x:'a -> > ?y:'b -> 'c -> 'c > but an expression was expected of type > unit -> 'd *) > > I don't understand why foo1 is fine and foo2 isn't. I would have > thought that I can use foo2 wherever I can foo1 since it has a > strictly more general type. > Am I missing something obvious here? Its probably due to the optional labels, this works: let y = () |! foo2 ?x:None ?y:None --Edwin