[Haskell-beginners] ($) operator

Jan Jakubuv jakubuv at gmail.com
Sun Jan 25 07:45:03 EST 2009


2009/1/24 John Hartnup <john.hartnup at gmail.com>:
>
> But is that it's only purpose? To placate the LISP haters by removing
> parentheses?
>

Also one important difference is that the standard application
operator (space) associates to the left while $ associates to the
right. It says how missing parenthesis are filled in.

For example

(a b c d e) stands for ((((a b) c) d) e)

while

(a $ b $ c $ d $ e) stands for (a (b (c (d e))))

Sometimes you need the former behavior sometimes the later. The $ is
useful for example when an argument to an unary function is itself a
function application. For example you can write

    filter (<4) $ map (+1) $ [100,99,1,2,3,4]

In this case you can think of $ to be like a "unix pipe".

Sincerely,
   jan.


More information about the Beginners mailing list