[Haskell-cafe] Question: Do block precedence

Jonne Ransijn yoyoyonny at gmail.com
Sun Feb 28 23:20:24 UTC 2016


Dear Haskell-Cafe mailing list people (?)
I've been writing parenthesis around do blocks since forever now, but I
don't get why they are necessary. I can't seem to come up with a program
where they are necessary. Am I missing something or are parenthesis around
do blocks nececairy for no reason? Since parsing 'do' blocks as if they
have parenthesis around them doesn't seem to break any code, why not do so?

    when (doBlocksNeedParenthesis) do putStrLn "This code is invalid."

    when (doBlocksNeedParenthesis) $ do putStrLn "This code is valid."

    when (doBlocksHaveInvisibleParenthesis) do putStrLn "These are equal v"

    when (doBlocksHaveInvisibleParenthesis) (do putStrLn "These are equal
^")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160229/a5f62333/attachment.html>


More information about the Haskell-Cafe mailing list