This is a known and documented deviation of GHC from the Haskell standard in default or Haskell 98 mode.
GHC has a language extension called NondecreasingIndentation
that can be used to trigger this behaviour. If enabled, a do
keyword introduces a new block even if the next token starts at the same indentation level as the surrounding block.
If you don’t want this, say either -XNoNondecreasingIndentation
or -XHaskell2010
(or use language pragmas accordingly).
You can view a pretty-printed version of the code that GHC parsed by passing the -ddump-parsed
flag to GHC. This will only partially remove layout (it does so for do-blocks, but e.g. not for let), but might still provide clues.