[Haskell-cafe] Typeclass resolution errors quite puzzling

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Mon Aug 15 17:07:58 UTC 2016

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'.

I believe the the missing Eq instance for B is the more useful bit of
information of these two, but I wouldn't mind an explanation of the
simplification steps that the compiler made to discover it. I'm a bit
worried though that such an explanation may be very long, and I expect
that it's not trivial to extract this information from ghc's constraint
based type checker. (In principle, -ddump-tc-trace prints all this
information, but it's far too verbose and cluttered by ghc internal



More information about the Haskell-Cafe mailing list