[GHC] #12142: -Wredundant-constraints warns about constraints introduced via type synonyms.

#12142: -Wredundant-constraints warns about constraints introduced via type synonyms. -------------------------------------+------------------------------------- Reporter: scshunt | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Linux Architecture: | Type of failure: Incorrect Unknown/Multiple | warning at compile-time Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I ran into this when using lens, here's a simplied example: {{{#!hs 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12142 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12142: -Wredundant-constraints warns about constraints introduced via type synonyms. -------------------------------------+------------------------------------- Reporter: scshunt | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I can see that's annoying, but it's hard to avoid. And it does tell you something useful, namely that `l` is less polymorphic, and therefore less usable, than it could be. It's tantalising -- `-Wredundant-constraints` really is jolly useful but it is also sometimes annoying. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12142#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12142: -Wredundant-constraints warns about constraints introduced via type synonyms. -------------------------------------+------------------------------------- Reporter: scshunt | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Linux | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett): In the interest of not getting drowned in complaints by the users of `lens` on GHC 8, we'll likely just add the constraint to `to` and rely on `{-# INLINE #-}` dropping it out in practice. This is a common enough scenario to warrant us eating the noise on our side. Of course, you'll get the same sort of thing if you go to declare a non- law abiding traversal as a fold, etc. There i'm afraid the only answer will be to squelch the warning. GHC can't see 'laws'. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12142#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC