Skip to content

Improve error message when using rec/mdo keyword without RecursiveDo extention.

GHC shows unhelpful error message when using rec keyword and/or mdo keyword without RecursiveDo extention.

module NoRecursiveDo where 

foo = do
    rec str <- return "foo"
    putStrLn str
$ ghc -c NoRecursiveDo.hs 

NoRecursiveDo1.hs:4:5:
    Parse error in pattern: rec
    Possibly caused by a missing 'do'?
module NoRecursiveDo2 where 

bar = mdo
    str <- return "bar"
    putStrLn str
$ ghc -c NoRecursiveDo2.hs 

NoRecursiveDo2.hs:4:9: parse error on input `<-'
module NoRecursiveDo3 where 

baz = mdo
    putStrLn "baz"
$ ghc -c NoRecursiveDo3.hs 

NoRecursiveDo3.hs:3:7:
    Not in scope: `mdo'
    Perhaps you meant `mod' (imported from Prelude)

I think that GHC should suggest to use RecursiveDo extention when using mdo/rec keyword.

Edited by Thomas Miedema
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information