caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Didier Cassirame <didier.cassirame@gmail.com>
To: "Milan Stanojević" <milanst@gmail.com>
Cc: "Török Edwin" <edwin+ml-ocaml@etorok.net>, caml-list@inria.fr
Subject: Re: [Caml-list] confusing type error when using function with optional arguments
Date: Fri, 16 Nov 2012 17:10:25 +0100	[thread overview]
Message-ID: <CA+Lkvypb8GzPAtus7WGfTPJwSD7t9XY4KnYijJkzCp5N9840nQ@mail.gmail.com> (raw)
In-Reply-To: <CAKR7PS-V-7X+GiAr0S7-mhiSWHixd7YcQo7X0+z3W2NOEuDVKQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]

And this works too :

let _ = () |! (fun z -> z);;

while this:

let _ = () |! (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 _ = 1 |! (fun ?x (z : int) -> z);;

didier


2012/11/16 Milan Stanojević <milanst@gmail.com>

> >> 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
>
> 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
>

[-- Attachment #2: Type: text/html, Size: 1802 bytes --]

      reply	other threads:[~2012-11-16 16:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16 14:50 Milan Stanojević
2012-11-16 15:58 ` Török Edwin
2012-11-16 16:05   ` Milan Stanojević
2012-11-16 16:10     ` Didier Cassirame [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+Lkvypb8GzPAtus7WGfTPJwSD7t9XY4KnYijJkzCp5N9840nQ@mail.gmail.com \
    --to=didier.cassirame@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=edwin+ml-ocaml@etorok.net \
    --cc=milanst@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).