[Haskell-cafe] Re: Error message reform (was: Strange type error with associated type synonyms)

Jeff Wheeler jeff at nokrev.com
Wed May 27 18:03:30 EDT 2009


On Thu, 2009-05-28 at 01:45 +0400, Bulat Ziganshin wrote:

> for me, it was better than ghc errmsg. main thing is that i don't feel
> automatically what is expected and what is inferred. here Hugs says
> that True is Bool and the remaining is Int, so i "feel" the situation

I absolutely agree about expected/inferred. I always forget which is
which, because I can figure both could apply to each.

Say, in this simple example:

> Prelude> let f = (+5)
> Prelude> f "abc"
> 
> <interactive>:1:2:
>     Couldn't match expected type `Integer'
>            against inferred type `[Char]'
>     In the first argument of `f', namely `"abc"'
>     In the expression: f "abc"
>     In the definition of `it': it = f "abc"

Does expected mean that, based on the type signature, it should be an
Integer, or based on the argument that I provided, it should be a
String? The same goes for the inferred type: it knows what the type of
the literal argument (String), so I would assume the inferred type was
the type in the function's signature. Unfortunately, my reasoning in
both cases can go the wrong way . . .

Better language may be much more helpful, although I'm not sure what may
be easier to interpret.

Jeff Wheeler



More information about the Haskell-Cafe mailing list