#7461: Error messages about "do" statements contain false information -----------------------------+---------------------------------------------- Reporter: EyalLotem | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.1 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- When GHC complains about a type-error in a "do" block, it says, for example:
{{{ main = putChar $ do getLine return 'x' }}} Results in an error: {{{ Couldn't match type `IO Char' with `Char' Expected type: IO String -> IO Char -> Char Actual type: IO String -> IO Char -> IO Char In a stmt of a 'do' block: getLine }}} I think this error message is pretty directly saying: The '''Actual''' type of "getLine" is: {{{ IO String -> IO Char -> IO Char }}} But that is of course non-sense! It is actually talking about the type of the (>>=) binding the "getLine" to the rest of the statements. But the (>>=) is not "in the statement" at all, so the error message is plainly wrong. It would be much better to talk about the type of the entire do block, or maybe the type of the last stmt in the do block (which is the same). For example, the error could be replaced by: {{{ Couldn't match type `IO Char' with `Char' Expected type: Char Actual type: IO Char In a stmt of a 'do' block: return 'x' }}} Or by: {{{ Couldn't match type `IO Char' with `Char' Expected type: Char Actual type: IO Char In 'do' block: `do { getLine; return 'x' }' }}} -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7461> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs