Improving "Empty 'do' block" error message
Motivation
With GHC-9.2 NondecreasingIndentation
will no longer be on by default. This means that users will run into the Empty 'do' block
error much more often. It would be nice if this error message gave users hints on how to fix it.
Context
There's broadly two ways you can get this error message. Either (a) you can write something with an explicit empty block:
a = do {}
or (b) you can write something like:
{-# LANGUAGE NoNondecreasingIndentation #-} -- implicit with GHC 9.2
b = do
print "doing things with X"
withX $ \x -> do
doStuffWithX x
where the layout rules lead to an empty block.
Real world example: https://github.com/TomMD/cipher-aes128/blob/0c3311cf9fc696c2bc22a890b409e5bf37541913/Setup.hs#L36
Proposal
When this error is thrown from a situation like (b), we should tell users:
- that the error can be avoided by indenting the lines of the inner do block
- that the error can be avoided by enabling
NondecreasingIndentation