Proposal: Add (&) to Data.Function

Oren Ben-Kiki haskell-oren at
Wed Nov 21 16:22:50 CET 2012

Admittedly the (flip ($)) operator is much more basic than lenses and
deserves some scrutiny. Chaining many operations "foo $ bar $ baz bag"
reads "the wrong way"; one has to maintain a mental stack of the operations
to figure out what's going on. OTOH, "bag & baz & bar & foo" reads "the
right way". "Take bag, and then apply baz, and then apply bar, and then
apply foo". Sort of like a UNIX pipeline.

I think (&) is worthy of inclusion in Prelude :-) That aside, in the
context of lenses, (record & foo .~ value) is even more essential than the
above general case. This is also the order that Structured/OO-style code is
written ( = value, in C/Ruby/Python/C++/Java/...) - for a good
reason. The short of it is that IMVHO, it does meet the high bar of a
universal single-character operator. I certainly use it a lot in my code.

As a side note, it would have been awesome if we could have used (:)
("record : field :~ value", and the truly elegant state-monad "field :=
value"). Alas, "everybody wants the (:)" - in Haskell it is used for cons,
and any operator starting with ":" must be a type operator, so this is out
of the question.

(&) seems like the best of the viable options, given (%) was snatched by
Data.Ratio. I still prefer (%) better, but I can live with (&).


On Wed, Nov 21, 2012 at 4:55 PM, David Menendez <dave at> wrote:

> On Tue, Nov 20, 2012 at 11:59 AM, Yitzchak Gale <gale at> wrote:
>>  It is a common idiom to write a sequence of composed combinators in
>>  reverse order to the way they would be written with ($) or (.). That
>>  naturally expresses the idea of the combinators as operations being
>>  applied in the given order.
> I think the bar should be pretty high before we add a third way to write
> function application to base. How common is this? Common among whom? Why
> can't the existing idioms of (.) and ($) work just as well?
> My own opinion is that this will only serve to confuse new people.
>> Discussion period: 2 weeks
> I am currently opposed.
> --
> Dave Menendez <dave at>
> <>
> _______________________________________________
> Libraries mailing list
> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list