-Wredundant-constraints emits warning even if constraint is narrowing type
I am not sure if this is the same as #12700 , but when having a constraint that uses type equality to narrow down a type, -Wredundant-constraints still emits the warning. My particular example is:
class RowCons (label :: Symbol) (ty :: k) (tail :: Row k) (row :: Row k)
| label row -> ty tail, label ty tail -> row
instance (RowDelete s r ~ tail, RowPrepend s ty tail ~ r) => RowCons s ty tail r
get :: forall s ty t r. RowCons s ty t r => Record r -> Proxy s -> ty
get _ _ = undefined
test_rec = get (Proxy :: Record ('Cons "foo" '[String])) (Proxy :: Proxy "foo")
With the RowCons constraint, the inferred type of test_rec is String (or [Char]), but without it it is an ambiguous ty
.
If the implementation of the type families is needed, they can be found here: https://github.com/jvanbruegge/Megarecord/blob/f65fa5f29dc393e32d42fc87872416ec02405784/src/Megarecord.hs
I tested this with 8.6.1 and 8.4.3