[Haskell-cafe] $ do?

Jonathan Geddes geddes.jonathan at gmail.com
Wed Dec 15 03:59:14 CET 2010


Quick question:

Why do I need the $ in the following bits of code?

> main = withSocketsDo $ do
>    --do something with sockets

> foo = fromMaybe 0 $ do
>    --do something in the maybe monad

I don't see (after admittedly only a minute or so thinking about it)
where any grammar ambiguities would be if 'do' had an implicit $ in
front of it:

> foo = fromMaybe 0 do
>     --do something in maybe

Though now that I've written it down, that is hard for me to visually
parse at a glance. I'm still curious though.

--Jonathan



More information about the Haskell-Cafe mailing list