[Haskell-cafe] Extending the idea of a general Num to other types?
Twan van Laarhoven
twanvl at gmail.com
Wed Sep 5 13:50:06 EDT 2007
Bulat Ziganshin wrote:
> Hello Simon,
> Wednesday, September 5, 2007, 11:19:28 AM, you wrote:
>> when you come across a case where GHC produces an
>> unhelpful message, send it in, along with the program
>> that produced it,
> i have put such tickets about year ago :) basically, it was about
> just changing wording: instead of "inferred" write:
> Expected type: ...
> Actual type: ...
This doesn't help enough. What is an 'expected' type? How is it not
'actual'? I want it to be immediatly clear which type is which.
Say I write
> "x" ++ 'y'
Right now the error is
Couldn't match expected type `[Char]' against inferred type `Char'
In the second argument of `(++)', namely 'y'
What always confuses me is which of these two types is the parameter I
gave, and which is the one expected by the function? Changing 'infered'
to 'actual' is an improvement, but it is not enough.
I would suggest:
(++) expects second argument to be of type '[Char]'
but was given 'y' of type 'Char'
Anothing thing that would be useful is *why* (++) expects a certian
type, say I enter
> "x" ++ [1::Int]
Instead of the above, the following would be more useful:
the function (++) has type: [a] -> [a] -> [a]
the first argument suggests: a = Char
the second argument suggests: a = Int
More information about the Haskell-Cafe