From: Lukasz Stafiniak <lukstafi@gmail.com>
To: Gilles Pirio <gilles.ocaml@googlemail.com>
Cc: "caml-list@yquem.inria.fr" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Improving OCaml's choice of type to display
Date: Mon, 12 Oct 2009 00:16:11 +0200 [thread overview]
Message-ID: <4a708d20910111516j2d19282bveb300ad1810d06f2@mail.gmail.com> (raw)
In-Reply-To: <605bf2750910111446m2d4b91cawf4dbadeed1b6ae88@mail.gmail.com>
You need to use a type alias:
# type ('a, 'b) func = 'a -> 'b;;
type ('a, 'b) func = 'a -> 'b
# let castro a = (fun _ -> a : ('a,'b) func);;
val castro : 'a -> ('b, 'a) func = <fun>
This is also how the compiler decides the arity of C functions from
"external" declarations, that is, it "counts the arrows" without
unfolding type aliases.
On Sun, Oct 11, 2009 at 11:46 PM, Gilles Pirio
<gilles.ocaml@googlemail.com> wrote:
> Hey Damien
>
> Sure, I fully understand that both types are equivalent given the rules
> governing the application operator. My point was more on the usability side,
> as the type display is primarily intended at helping the programmer to
> quickly figure out type mismatch. So I'd think having a display allowing to
> quickly distinguish between the noe and castro functions below would be a
> good thing, especially for beginners. I've been using ocaml for a few years
> now, and I have to say that it's not a major issue any more - just wanted to
> give some feedback about this.
>
> Thanks
> Gilles
>
>
> # let noe a b = a;;
> val noe : 'a -> 'b -> 'a = <fun>
> # let castro a = fun _ -> a;;
> val castro : 'a -> 'b -> 'a = <fun>
>
next prev parent reply other threads:[~2009-10-11 22:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-09 1:40 Yaron Minsky
2009-10-09 1:53 ` Yaron Minsky
2009-10-11 14:57 ` [Caml-list] " Jun Furuse
2009-10-11 15:12 ` Yaron Minsky
2009-10-11 15:24 ` Jun Furuse
2009-10-11 19:57 ` Gilles Pirio
2009-10-11 21:17 ` [Caml-list] " Damien Guichard
2009-10-11 21:46 ` Gilles Pirio
2009-10-11 22:16 ` Lukasz Stafiniak [this message]
2009-10-09 7:33 ` Andrej Bauer
2009-10-09 9:58 ` Yaron Minsky
2009-10-09 10:54 ` Alp Mestan
2009-10-09 11:15 ` Yaron Minsky
2009-10-09 14:18 ` Damien Guichard
2009-10-09 14:44 ` Vincent Aravantinos
2009-10-09 15:27 ` David Allsopp
2009-10-09 16:52 ` Yaron Minsky
2009-10-09 18:23 ` Damien Guichard
2009-10-09 18:14 ` Stephen Weeks
2009-10-10 15:08 ` Damien Guichard
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=4a708d20910111516j2d19282bveb300ad1810d06f2@mail.gmail.com \
--to=lukstafi@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=gilles.ocaml@googlemail.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