The following program has a parse error: the line _x :: () <- pure ()
shouldn’t be indented. But the error message is really bad. It’s about the do
in the True
case branch! Does anyone understand why? (It seems to really subtly depend on some other features of the program too. If they’re changed then the error message improves.)
foo :: IO ()
-- The error changes to something more reasonable
-- if this do is removed.
foo = do
case True of
-- There's an error message on this "do"
--
-- error: [GHC-06446]
-- do-notation in pattern
True -> do
pure ()
False -> do
-- The error changes to something more
-- reasonable if this let is removed
let _ = ()
-- The error changes to something more
-- reasonable if the type siganture is
-- removed
_x :: () <- pure ()
pure ()