On 9 Aug 2007, at 8:41 am, David Roundy wrote:
I may be stating the obvious here, but I strongly prefer the do syntax. It's nice to know the other also, but the combination of do +indenting makes complicated code much clearer than the nested parentheses that would be
required with purely >>= syntax.

Er, what nested parentheses would those be?
        do e            => e

        do e            => e >>
           rest            rest'

        do p <- e    => e >>= \p ->
           rest            rest'

        do let d        => let d in
           rest            rest'

We get extra >>, >>=, \, ->, and "in" tokens, but no new parentheses.

The example in the Report makes this clear:

        do putStr "x: "
           l <- getLine
           return (words l)

desugars to

        putStr "x: "     >>
        getLine          >>= \l ->
        return (words l)

with no extra parentheses.
[Not that this actually works in GHC 6; the implied flush isn't done.]


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to