`Wredundantconstraints` depends on the ordering of constraints with overlapping superclasses
Summary
The Wredundantconstraints
flag does not result in a warning when it should, due to the ordering of constraints.
Steps to reproduce
In the following code
{# OPTIONS_GHC Wredundantconstraints #}
{# OPTIONS_GHC Werror #}
module Test where
class A a where
a :: a > a
class A a => B a where
b :: a
class A a => C a where
noWarning :: (C a, B a) => a
noWarning = a b
warning :: (B a, C a) => a
warning = a b
I get only the error
Test.hs:17:1: error: [Wredundantconstraints, Werror=redundantconstraints]
• Redundant constraint: C a
• In the type signature for:
warning :: forall a. (B a, C a) => a

17  warning :: (B a, C a) => a
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expected behavior
There should be two errors, one for warning
and one for noWarning
. This would be in line with the behaviour of GHC with the constraints (Eq a, Ord a)
and (Ord a, Eq a)
, both of which result in warnings in similar situations.
Environment
 GHC version used: 8.6.5