[GHC] #11582: Redundant constraints warning complains that (a ~ b) is redundant

GHC ghc-devs at haskell.org
Tue Feb 16 11:30:55 UTC 2016


#11582: Redundant constraints warning complains that (a ~ b) is redundant
-------------------------------------+-------------------------------------
           Reporter:  bgamari        |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.0.1
          Component:  Compiler       |           Version:  8.0.1-rc2
  (Type checker)                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Incorrect
  Unknown/Multiple                   |  warning at compile-time
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Lemming came up with an interesting example where the redundant
 constraints warning is arguable a bit too trigger-happy in #10635.
 Consider,
 {{{#!hs
 asTypeOf :: a -> a -> a
 asTypeOf x _ = x
 }}}
 We could equivalently rewrite this with an equality constraint,
 {{{#!hs
 asTypeOf1 :: (a ~ b) => a -> b -> a
 asTypeOf1 x _ = x
 }}}
 If compiled with GHC 8.0 with `-Wredundant-constraints` we see a warning,
 {{{
 hi.hs:4:1: warning:
     • Redundant constraint: a ~ b
     • In the type signature for:
            asTypeOf1 :: (a ~ b) => a -> b -> a
 }}}
 But is this really unused? We may not have referenced the constraint in
 the RHS, but surely the typechecker has gleaned something from it.

 Perhaps we should simply ignore equality constraints when generating
 redundant constraint warnings?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11582>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list