Proposal: Add (&) to Data.Function

Edward Kmett ekmett at gmail.com
Tue Nov 20 19:52:08 CET 2012


On Tue, Nov 20, 2012 at 1:44 PM, Bryan O'Sullivan <bos at serpentine.com>wrote:

> On Tue, Nov 20, 2012 at 10:39 AM, Edward Kmett <ekmett at gmail.com> wrote:
>
>> We converted to (&) because of its incredible terseness and general lack
>> of use across hackage. For DSL purposes, to me it is key that this operator
>> be as succinct as possible and (&) is remarkably underutilized in haskell
>> libraries today, due to the fact that (|) is taken by syntax, and our
>> C-inspired brains tend to pair them.
>>
>
> That seems fairly convincing to me. Count me as a +1 on Yitz's original
> proposal of & *or* on |> instead, whichever wins in the court of popular
> opinion.
>
> I assume this will have the not-very exciting type of
>
> (a -> b) -> (b -> c) -> a -> c
>
> ?
>

(&) :: a -> (a -> b) -> b

it is just  flip ($)

>>> ("hello","world")  &  _1.traverse %~ toUpper  & _2 .~ 42
("HELLO",42)

could be written

_2 .~ 42 $ _1.traverse .~ toUpper $ ("hello","world")

but that goes in the opposite direction of the corresponding code for
working with the state monad with lenses:

foo = do
   _1.traverse %= toUpper
   _2 .~ "42"

-Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20121120/8adde201/attachment.htm>


More information about the Libraries mailing list