Inconsistent warnings for unused binders in type and instance declarations
Consider compiling this with
class C a where op :: a -> a instance C (Maybe a) where op x = x
We get no warnings, even though
a is patently unused.
But suppose we add an associated type
class C a where type T a op :: a -> a instance C (Maybe a) where type T (Maybe a) = Int -- Warning on this line op x = x
Now we get a warning for an unused binding for
a on the
Edward complained about this inconsistent behaviour in this email thread.
- Currently GHC does not warn about type variables bound in the instance head but unused in the
wherepart. Fixing that might be a good idea, but would be a new feature.
- However, given that we don't warn about them, we should definitely not warn about instance type variables being unused in an associated type. But we could warn about ones specific to the associated type itself. Eg
class C2 a where type T2 a b instance C2 (Maybe a) where type T2 (Maybe a) x = Int -- Line XXX
Here, on line
XXX, we might reasonably warn about the unused
x, but not about the unused