
On 15.11.2016, David Turner wrote:
The outer do block should be desugared first, and the `putStrLn "done"` has the same indent as the `if` so it gets a semicolon, in that block, meaning it looks like this:
main = do { if True then do putStrLn "A" else do -- putStrLn "B" ; putStrLn "done" }
That's what one would expect. Except that GHC treats the 'putStrLn "done"' as part of the do-block in the else branch by default. This is due to the NondecreasingIndentation extension which is enabled by default (see https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/bugs.html#co...). With the option -XNoNondecreasingIndentation (or -XHaskell2010) GHC does produce an error message because of the empty do-block. Bernhard