[Haskell-cafe] a regressive view of support for imperative programming in Haskell

ok ok at cs.otago.ac.nz
Thu Aug 9 21:19:12 EDT 2007

On 10 Aug 2007, at 6:42 am, David Roundy wrote:
> do x1 <- e1
>    if x1 then do x2 <- e2
>                  xx <- if x2 then e3
>                              else do x4 <- e4
>                                      x5 <- e5
>                                      e6 x4 x5
>                  e7 xx x1
>          else do x8 <- e8
>                  x9 <- e9
>                  e10 x8 x9 x1
>    x11

Granted.  If you desugar nested dos then you need extra parentheses.
(Basically, the invisible curly braces turn visible as parentheses.)
But then, I don't regard this example as readable, and in true
"lots of little functions" style would name the steps.  I especially
dislike the irregular indentation one gets with do/if/do.

Anyone remember when Haskell extended list comprehension syntax to
monads?  Just as I was about to get my head around it, it went away.

> This is the beauty of the do notation, it
> allows one to write actual real complicated monadic code in a form
> that is actually comprehensible.

It seems we are now in complete agreement except for "comprehensible".

More information about the Haskell-Cafe mailing list