Don't warn about redundant constraints for type equalities
With -Wall, the following code
{-# LANGUAGE TypeFamilies #-}
type family Foo x where
Foo Double = Int
foo :: (RealFrac a, Integral b, b ~ Foo a) => a -> b
foo = round
produces the warning
• Redundant constraint: b ~ Foo a
• In the type signature for:
foo :: (RealFrac a, Integral b, b ~ Foo a) => a -> b
Technically, I suppose this is correct in the sense that if we remove the constraint b ~ Foo a, foo still compiles. However, the meaning changes without the type equality, because the function I wrote is equivalent to foo :: (RealFrac a, Integral (Foo a)) => a -> Foo a (which requires -XFlexibleContexts), while the function it suggests is the much more general foo :: (RealFrac a, Integral b) => a -> b. Since this is the case, I think the warning is invalid.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |