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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 5A76E7EE20 for ; Fri, 16 Nov 2012 15:51:36 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of milanst@gmail.com) identity=pra; client-ip=209.85.210.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of milanst@gmail.com designates 209.85.210.54 as permitted sender) identity=mailfrom; client-ip=209.85.210.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-da0-f54.google.com) identity=helo; client-ip=209.85.210.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="postmaster@mail-da0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As8GADZSplDRVdI2k2dsb2JhbABEhVcBRrs8AQMBA3wIIwEBAQEJCQsJFAQjgkgEGQEbHgMSEA8CJgIkAREBBQEWDIgNAQMPnHyCb4tkT4J4hG4KGScNWYh1AQUMgRaPC4ETA4hajSKOYhYphC8 X-IronPort-AV: E=Sophos;i="4.83,265,1352070000"; d="scan'208";a="181855784" Received: from mail-da0-f54.google.com ([209.85.210.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 16 Nov 2012 15:51:35 +0100 Received: by mail-da0-f54.google.com with SMTP id z9so1507336dad.27 for ; Fri, 16 Nov 2012 06:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=AjkTF9S0MEgU4SKyu+FBV8RqI+n2ai0KHf51PIdJmN4=; b=SLYUUT+4AJUj8Fl8e2dnSyuNIEstTIqKoeBL5Bfy7sF6VM0+HYFzspO/jvkl7dkvn0 db1kLgFDQtkqzOygDHG8lJFEa6SC9D22AenCrA6phnEBN2MOwx3Gp5cZuO8rrdFilzKr 2goPRkeEyQnOS9b/92cCUjrD55YTX0j54zJnLJIf2UBPdMnrZppqiWbTKtSU17clGiS0 vpNrrJJNuKiYdd+BjcpL32rVsc0uyAG0USDDNgApNwT7Dj+pwRm1H4JVki+i/KS6nFO6 NhM70Mj+dzzehvogkTTi98fz3KHrVo0ONyQKTdvJRQXULimh4Dz+QITrCE2EUsZeDhyQ 5W9g== Received: by 10.66.78.136 with SMTP id b8mr13530174pax.26.1353077494241; Fri, 16 Nov 2012 06:51:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.68.29.99 with HTTP; Fri, 16 Nov 2012 06:50:53 -0800 (PST) From: =?UTF-8?Q?Milan_Stanojevi=C4=87?= Date: Fri, 16 Nov 2012 09:50:53 -0500 Message-ID: To: Caml List Content-Type: text/plain; charset=UTF-8 Subject: [Caml-list] confusing type error when using function with optional arguments 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? %revapply is not important here I just wanted to include context. I get the same behavior in 3.12.1 and 4.00.1