[Haskell-cafe] Strange type error with associated type synonyms

Henning Thielemann lemming at henning-thielemann.de
Wed May 27 18:06:36 EDT 2009

On Thu, 28 May 2009, Bulat Ziganshin wrote:

> read x
> Error: type of x is Integer
> while type of read argument should be String

I also have my problems with "inferred/expected" and find your suggested 
message easier to understand in this case. But can it be generalized? I 
think that "inferred" and "expected" are quite arbitrary terms for the 
user, since he does not know, what GHC first believed to know for sure.

Prelude> let a = 'a'; b = "b" in a==b

     Couldn't match expected type `Char' against inferred type `[Char]'

Is the type of 'a' wrong or that of 'b'? The compiler cannot know. It can 
only state that the types mismatch. The order in which it infers is not 
obvious for the user.

More information about the Haskell-Cafe mailing list