Proposal: Add (&) to Data.Function

Edward Kmett ekmett at gmail.com
Tue Nov 20 22:21:07 CET 2012


$. is kind of the worst of all possible worlds to me.

(|>) at least has the ML precedent going for it, but ($.) using the . to
indicate the side that the function is on offers very little to visually
distinguish it from ($) and no such precedent to motivate it.

The first time I read your post I read the . as the end of sentence marker.
=P

-Edward

On Tue, Nov 20, 2012 at 4:08 PM, Gábor Lehel <illissius at gmail.com> wrote:

> Another option that was raised in a mailing list thread at some point
> (I think it was one about records): $.
>
> The idea being to evoke the dot operator of object-oriented languages
> together with the existing ($) of function application.
>
>     theList $. filter even $. map (*2) $. sum
>
> If you read it by focusing on the dots as in an OO language it sort of
> works. Not sure how I feel about it, throwing it out there. As a
> candidate for the least bad choice I think it at least qualifies.
>
> On Tue, Nov 20, 2012 at 5:59 PM, Yitzchak Gale <gale at sefer.org> 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.
> >
> >  This comes up so often, and is commonly used so many times in a single
> >  expression, that Control.Arrow.>>> is far too wordy, and even a two-
> >  character operator is awkward.
> >
> >  Surprisingly, until recently the operator (&) was still not used in any
> >  of the popular libraries, and its name naturally expresses the idea we
> are
> >  looking for. This operator has now been defined in the lens package. We
> >  hereby propose to move it to its natural home for more general use,
> >  Data.Function.
> >
> >  As in the lens package, we define the operator as a flipped version of
> >  ($), but with slightly higher precedence for better interaction with
> >  ($), and with left associativity. This definition has already proven
> >  useful and convenient even in the presence of the large  and varied
> corpus
> >  of combinators and operators in the lens package. (There it was formerly
> >  known as (%), but that clashed with the usual meaning of (%) from
> >  Data.Ratio.)
> >
> >  infixl 1 &
> >  (&) :: a -> (a -> b) -> b
> >  a & f = f a
> >  {-# INLINE (&) #-}
> >
> > Discussion period: 2 weeks
> >
> > http://hackage.haskell.org/trac/ghc/ticket/7434
> >
> > Thanks,
> > Yitz
> >
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org
> > http://www.haskell.org/mailman/listinfo/libraries
> >
>
>
>
> --
> Your ship was destroyed in a monadic eruption.
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20121120/bf981cd5/attachment.htm>


More information about the Libraries mailing list