Redundant constraints warning complains that (a ~ b) is redundant
Lemming came up with an interesting example where the redundant constraints warning is arguable a bit too trigger-happy in #10635 (closed). Consider,
asTypeOf :: a -> a -> a asTypeOf x _ = x
We could equivalently rewrite this with an equality constraint,
asTypeOf1 :: (a ~ b) => a -> b -> a asTypeOf1 x _ = x
If compiled with GHC 8.0 with
-Wredundant-constraints we see a warning,
hi.hs:4:1: warning: • Redundant constraint: a ~ b • In the type signature for: asTypeOf1 :: (a ~ b) => a -> b -> a
But is this really unused? We may not have referenced the constraint in the RHS, but surely the typechecker has gleaned something from it.
Perhaps we should simply ignore equality constraints when generating redundant constraint warnings?
|Component||Compiler (Type checker)|