From: bluestorm <bluestorm.dylc@gmail.com>
To: Michael Ekstrand <michael@elehack.net>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Option functions (or lack thereof) + operator for composition
Date: Tue, 16 Nov 2010 16:18:02 +0100 [thread overview]
Message-ID: <AANLkTim2rXXvtUMcjC90fhR379RE8TEk+uRFz5U239DJ@mail.gmail.com> (raw)
In-Reply-To: <4CE294A1.5050100@elehack.net>
[-- Attachment #1: Type: text/plain, Size: 1508 bytes --]
On Tue, Nov 16, 2010 at 3:26 PM, Michael Ekstrand <michael@elehack.net>wrote:
>
> Batteries provides operators for things like this. It defines the '**>'
> operator for function application; it's an odd name, but it has the
> right associativity. As Dmitry mentioned, some override (&). Batteries
> also provides composition operators |- and -|, and a pipeline operator
> |> (opposite of **>). With that operator, you can write:
>
> f x y |> ignore
>
> thereby putting the emphasis on "f x y" and relegating "ignore" to a
> cleanup at the end.
>
> - Michael
(<|) as inverse of (|>) is also available. It doesn't have the "right"
associativity, but you can easily use (f -| g -| h <| x) instead of (f **> g
**> h **> x).
Though I find the application-as-pipeline style quite readable in some
cases, I think that in general it is more often superfluous than not.
Besides, as mentioned recently on this list, overuse of the function
composition operators (|-) and (-|) are also call for troubles with the
value restriction.
All in all, I think it's reasonable to stay conservative and not advertise
funky binary operators too loudly.
That said, domain-specific binary operators are certainly useful for
readability in some contexts --- that's what an infix operator is anyway :
an unreadable-by-design symbol that only get meaning by domain-specific
conventions. Local open in, available by standard since OCaml 3.12, allow us
to neatly encapsulate such domain-specific notations into OCaml modules.
[-- Attachment #2: Type: text/html, Size: 1973 bytes --]
next prev parent reply other threads:[~2010-11-16 15:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 11:27 Serge Le Huitouze
2010-11-16 11:49 ` [Caml-list] " David Allsopp
2010-11-16 14:23 ` Michael Ekstrand
2010-11-16 13:30 ` Jacques Garrigue
2010-11-16 13:52 ` Serge Le Huitouze
2010-11-16 14:19 ` dmitry grebeniuk
2010-11-16 14:26 ` Michael Ekstrand
2010-11-16 15:18 ` bluestorm [this message]
2010-11-16 15:26 ` bluestorm
[not found] <1853021343.44703.1289906871683.JavaMail.root@zmbs4.inria.fr>
2010-11-16 11:43 ` Thomas Gazagnaire
2010-11-16 11:51 ` Gabriel Kerneis
2010-11-16 17:45 ` Martin Jambon
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=AANLkTim2rXXvtUMcjC90fhR379RE8TEk+uRFz5U239DJ@mail.gmail.com \
--to=bluestorm.dylc@gmail.com \
--cc=caml-list@yquem.inria.fr \
--cc=michael@elehack.net \
/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