[Haskell-cafe] Typeclass resolution errors quite puzzling
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Mon Aug 15 14:58:04 UTC 2016
On Mon, Aug 15, 2016 at 03:50:03PM +0100, Tom Ellis wrote:
> On Mon, Aug 15, 2016 at 03:40:46PM +0100, Malcolm Wallace wrote:
> > It is no surprise that the instance Eq A is not mentioned, because there
> > is a perfectly valid instance for it already, and it contains no error.
>
> I disagree.
>
> There is no valid instance for Eq (A B), because all that the compiler knows
> is that 'Eq B => Eq (A B)', and there is no 'Eq B'.
>
> There are two separate issues here.
>
> 1. The reason the compilation fails is that there is no instance 'Eq (A B)'.
>
> 2. The reason there is no instance 'Eq (A B)' is that there is no instance
> 'Eq B'.
>
> In my opinion it would be most helpful to the user to mention both 1 and 2.
> In fact it's likely to be very confusing if you don't mention both of them!
By the way, I agree with the spirit of this:
> It points directly to the missing instance, namely Eq B. If you add an
> instance for Eq B, the program will work ... the error message is
> correctly steering you away from considering the As, and telling you to
> consider the Bs instead.
but I don't see why the compiler shouldn't be even *more* helpful in its
steering and explain how and why it came to need 'Eq B'.
Tom
More information about the Haskell-Cafe
mailing list