[Haskell-beginners] Right-associating infix application operators

Antoine Latter aslatter at gmail.com
Tue Jul 6 07:10:06 EDT 2010


Hi Tom,

There are no additional benifits to the '$' function - you pretty much have
it.

Wait - one more. It can be used as a 'section' like any other binary
operator, so ($ 4) :: (Int -> a) -> a. But that doesn't come up a whole lot.
This is much like how (* 5) 6 == 30.

Antoine

On Jul 6, 2010 6:00 AM, "Tom Hobbs" <tvhobbs at googlemail.com> wrote:

In people's responses to my serialization questions, I've seen them using $.

I didn't know what it was so I've looked it up.  Can someone please confirm
my understanding of what it does, please?

According to http://en.wikibooks.org/wiki/Haskell/Practical_monads, after
the second code sample in the "Return Values" section, it seems to suggest
that $ is only used to avoid using so many brackets.  Which seems to make
sense, but looking at it's definition in Prelude I really can't see why it's
useful.

Yitz gave me the code;

fmap (runGet $ readNames n) $ L.hGetContents h

So can I rewrite this without the $ like this?

fmap (runGet (readNames n)) (L.hGetContents h)

Is there any additional benefit to using $ than just not having to write as
many brackets?

Thanks,

Tom

_______________________________________________
Beginners mailing list
Beginners at haskell.org
http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100706/3bac7e40/attachment-0001.html


More information about the Beginners mailing list