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 D0A2D7EE20 for ; Fri, 16 Nov 2012 17:10:47 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of didier.cassirame@gmail.com) identity=pra; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="didier.cassirame@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of didier.cassirame@gmail.com designates 209.85.219.54 as permitted sender) identity=mailfrom; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="didier.cassirame@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-oa0-f54.google.com) identity=helo; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="didier.cassirame@gmail.com"; x-sender="postmaster@mail-oa0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtcCAAVkplDRVds2m2dsb2JhbABEhh6pdok4AYkRCCMBAQEBAQgJCwkUJ4IeAQEEASMEGQEbEgsBAwwGBQQHGh0CAiEBAREBBQEKEgYTCAqHaAEDCQYLn26LZE+CeIRyChknAwpZiHUBBQyLPoRjgRMDlCeBVYEcihaDMBYphBI X-IronPort-AV: E=Sophos;i="4.83,265,1352070000"; d="scan'208";a="181872315" Received: from mail-oa0-f54.google.com ([209.85.219.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 16 Nov 2012 17:10:47 +0100 Received: by mail-oa0-f54.google.com with SMTP id n9so5012229oag.27 for ; Fri, 16 Nov 2012 08:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=PgdJOml+fJwrHD5ElMknCxX1P0RSfMuZ9iT5yGs27yM=; b=JRJeBVRdwnWQDuj+Jx/auJ6lop5NMpSF+TnJxV9lDM2vdqhTzeaferir5JvGRi+NJS WmGe6bRUZhwSnQR5DvgZ+9YEh+2mBeEX9Zl2Q8Ji5vH6xyqYezeSDoTuhz6Br+VoXHAl DHhX9KLmybGL2DMSC8UZAkRzsVek2vdi03Eq2HQly5ZETQy4d4SztXyiZC0xq5qBqTBL bIWCjFmIc/Qzm2Pg/14XA7wPYsExu4vCxtYtsbjav2StYcIWNeNswIamN+xaRlN1ZThM 3aZr5RuOwuwPxQLLLDRQ+2T65cnASW+YWtqPXLue2CN9Ruysl8vIIALkPDmlpgqhSw0m HAtg== Received: by 10.182.184.102 with SMTP id et6mr4126532obc.102.1353082246218; Fri, 16 Nov 2012 08:10:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.60.137.198 with HTTP; Fri, 16 Nov 2012 08:10:25 -0800 (PST) In-Reply-To: References: <50A662C2.8000402@etorok.net> From: Didier Cassirame Date: Fri, 16 Nov 2012 17:10:25 +0100 Message-ID: To: =?UTF-8?Q?Milan_Stanojevi=C4=87?= Cc: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= , caml-list@inria.fr Content-Type: multipart/alternative; boundary=f46d0444e8a5a344d904ce9f0215 Subject: Re: [Caml-list] confusing type error when using function with optional arguments --f46d0444e8a5a344d904ce9f0215 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable And this works too : let _ =3D () |! (fun z -> z);; while this: let _ =3D () |! (fun ?x z -> z);; doesn't. It appears that when the mandatory parameter is typed, the inference kernel doesn't fail, as seen with the unit type. Here's another working example: let _ =3D 1 |! (fun ?x (z : int) -> z);; didier 2012/11/16 Milan Stanojevi=C4=87 > >> 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 =3D () |! foo2 ?x:None ?y:None > > The question is why foo1 doesn't need this and foo2 does. > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --f46d0444e8a5a344d904ce9f0215 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable And this works too :

let _=C2=A0=3D () |! (fun z -> z= );;

while this:

let _ =3D= () |! (fun ?x z -> z);;

doesn't.

It appears that when the mandatory parameter is typed, the inference k= ernel doesn't fail, as seen with the unit type. Here's another work= ing example:

let _ =3D 1 |! (fun ?x (z : int) ->= ; z);;

didier


2012/11/16 Milan Stanojevi=C4=87 <milanst@gmail.com>
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">
>> 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 =3D () |! foo2 ?x:None ?y:None

The question is why foo1 doesn't need this and foo2 does.

--
Caml-list mailing list. =C2=A0Subscription management and archives:
ht= tps://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--f46d0444e8a5a344d904ce9f0215--