Skip to content

-Wredundant-constraints warns about constraints introduced via type synonyms.

I ran into this when using lens, here's a simplied example:

l :: Getter [a] Int
l = to length

In this case, Getter introduces constraints (Functor f, Contravariant f), but the Functor constraint is not used. This leads to a warning from -Wredundant-constraints:

<interactive>:1:6: warning: [-Wredundant-constraints]
    • Redundant constraint: Functor f
    • In the type signature for:
           l :: (Contravariant f, Functor f) => (Int -> f Int) -> [a] -> f [a]

This shouldn't warn, because the constraints were introduced by type synonym and so may well be opaque to the user.

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information