

(&) = flip ($) in Haskell - adito
http://vemod.net/ampersand

======
tel
This is included in the popular Control.Lens package since it sometimes has
natural right-to-left composition. It's still unnatural for 99% of Haskell
code you'll see, but (&) = flip ($) seems to be cemented as the "correct"
representation now.

It's a wontfix on the language spec itself, though.

~~~
gizmo686
It was closed with the message: "I'm closing this ticket while the discussion
is going on on the libraries list. Please reopen, or open a new ticket, if a
positive decision is reached" [1]

The discussion itself [2] is basically bikeshedding at this point.

[1] <http://hackage.haskell.org/trac/ghc/ticket/7434> [2]
[http://www.haskell.org/pipermail/libraries/2012-November/018...](http://www.haskell.org/pipermail/libraries/2012-November/018832.html)

I took both of these links directly from lelf's comment in this thread.

------
lelf
Yep, except that it is not there.

There was quite a discussion about (&), (|>) and what not on the mailing list.
No consensus…

[http://www.haskell.org/pipermail/libraries/2012-November/018...](http://www.haskell.org/pipermail/libraries/2012-November/018832.html)

<http://hackage.haskell.org/trac/ghc/ticket/7434>

~~~
nrlucas
F# obviously approves |>, but in my software project that has been continually
maintained for ten years, we introduced -->. Now re-factoring our project we
use |>. It kind of messes with my sight against pattern matching in OCaml
though.

------
fosap
I guess F# and livescript use |> and <|. I like them better than $ and &.

Like

[3,1,2,3,41,2,4] |> sort (>) |> map \x->x*x

------
vitno
while I recognize this is tongue-in-cheek, just as a PSA...

When trying to hack something together, excellent.

When trying to learn a new language, aim for idiomatic usage.

~~~
Evbn
Haskell is like Lisp: so expressive that it supports many idiomatic styles of
usage, depending on application domain.

------
Tyr42
Diagrams defines # to be reverse function application.

------
kenko
I used ¢ as flip ($).

~~~
kenko
I guess this is too heavyweight, after all:

    
    
        Prelude GOA> (return [1..]) >>= return . map (^ 2) >>= return . takeWhile (< 64)
        [1,4,9,16,25,36,49]

------
taejo
Diagrams uses (#) for this.

------
Evbn
You'll flip your id

($) = id Except that id works on values and functions, but $ only works on
functions.

(&) = flip id

$ is just an less-expressive alias for id that looks prettier (and has
different precedence/associativity when used infix)

~~~
tel
No, not strictly true! ($) has a compiler hack to let it handle
impredicativity.

    
    
        import Control.Monad.ST
    
        infix 0 %
        (%) = id
    
        runST $ return () -- :: ()
        runST % return () -- Type error!
    
        Couldn't match expected type `forall s. ST s a0'
                    with actual type `m0 a1'
        In the return type of a call of `return'
        In the second argument of `id', namely `(return ())'
        In the expression: runST `id` (return ())

