NondecreasingIndentation is problematic when the indentation can't be decreased
Consider the following program, which was deliberately mis-indented (someone playing with an exercise with deliberate errors and being confused by the result):
module Print3Broken where printSecond :: IO () printSecond = do putStrLn greeting -- Yarrrrr out of scope main :: IO () main = do putStrLn greeting printSecond where greeting = "Yarrrrr"
-XNondecreasingIndentation on by default, this will parse as long as the definition of
main (or any other definition) is not present after the
do block. But there is no legal way to have a definition after the
do because it is not possible to unindent from column 1 --- and the resulting parse error is a bit confusing and gives no hint that
NondecreasingIndentation applied to the
do is the cause.
NondecreasingIndentation should not be applied when it is impossible to decrease the indentation.