But what does it mean at all to have a redundant constraint?
If you can remove a constraint and the function is still type-correct then you might call the constraint redundant.
singleton :: (Ord a) => a -> Set a
the compiler should warn about the redundant
The programmer still might want that constraint in order to be more flexible at later internal refactorings.
But what about this:
asTypeOf1 :: (a ~ b) => a -> b -> a asTypeOf1 x _ = x
ghci-184.108.40.20660214 -fwarn-redundant-constraints warns about the equality constraint.
However, you might write it the Haskell 98 way:
asTypeOf :: a -> a -> a asTypeOf x _ = x
There is no constraint to complain about, but the function has not the most general type. Is this a redundant constraint, too?
ADDITION by @k-bx: it's also true for
HasCallStack constraint that you do want to have. This has led me to put
-fno-warn-redundant-constraints in my