Skip to content

Wrong error message for unknown Instance

This type-incorrect program gives a wrong error message:

main = tmp "hello"
  where tmp :: String -> IO ()
        tmp = sequence_ lst
        lst = [putStrLn "hi"]

Namely:

    Couldn't match expected type `IO ()' with actual type `()'
    Expected type: String -> IO ()
      Actual type: String -> ()
    In the return type of a call of `sequence_'
    In the expression: sequence_ lst

I would not expect the "actual type" to be "String -> ()", but rather "IO ()". Note: GHC expects that "(->) String" is a monad.

Trac metadata
Trac field Value
Version 7.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information