
Hi Kim-Ee, On Fri, Mar 28, 2014 at 01:47:02AM +0700, Kim-Ee Yeoh wrote:
On Thu, Mar 27, 2014 at 9:50 PM, Semen Trygubenko / Семен Тригубенко < semen@trygub.com> wrote:
(1) Why are we biasing the programmer to expect one thing (the function is wrong) and not the other (r is wrong)? I.e., would the programmer benefit from inclusion of the "alternative view" as well?
The error message isn't really pointing blame, it's just saying, "Yo, I'm stuck at this stage of the inference algorithm so I'm sending the ball back into your court."
Yet it is using words "actual" and "expected" in the output, which can be taken as a gospel by newbies [ or professionals in an emergency ;) ].
But you do have a point.
Thanks!
That said, after a certain amount of experience with ghc, one learns to quickly scan the errors for key bits.
I agree — all the information is there, it's just hard to see it sometimes. :) E.g., earlier in this thread someone was asking about types of entities involved. Anything that can decrease the amount of staring at the type error is good, IMHO. And this is such a cheap modification — changing the way the type checker output looks!
The 'alternative view' repeats essentially the same info twice and including it doubles the amount of spew-out.
Good point (re amount of spew-out). However, I believe both types should be mentioned, as one is as likely to be wrong as the other. If we are outputting it like that (i.e., one of the two, not both) and care about the amount of output, why are we not outputting the less complex type of the two types involved in a mismatch? r would certainly win that contest. IMHO, I don't think word "expected" is a great word to use here. (length . head) expects to be fed [[a2]] as much as r expects it should be passed into to functions that take Int. ghc should "expect" us to change (length . head) to take Int as much as it "expects" us to fix r to be of type [[a2]]. How about this: test.hs:10:15: Couldn't match type `[[a2]]' with `Int' (length . head) :: [[a2]] -> Int r :: Int In the first argument of `(==)', namely `(length . head) r' In the expression: (length . head) r == 0 ? Thank you, S. -- Семен Тригубенко http://trygub.com