[GHC] #12810: -Wredundant-constraints doesn't factor in associated type families

GHC ghc-devs at haskell.org
Sat Nov 5 20:51:59 UTC 2016


#12810: -Wredundant-constraints doesn't factor in associated type families
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect         |  Unknown/Multiple
  error/warning at compile-time      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 This also came up in Phab:D2636 (the fix for #2721 and #8165), since you
 can now use `GeneralizedNewtypeDeriving` to derive an instance for a class
 with an associated type family on a newtype. But in
 [https://phabricator.haskell.org/D2636#77793 this example]:

 {{{#!hs
 {-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies #-}
 class C a where
   type T a

 newtype Identity a = Identity a deriving C
 }}}

 If you compile this with `-Wredundant-constraints`, GHC will look at the
 derived instance:

 {{{#!hs
 instance C a => C (Identity a) where
   type T (Identity a) = T a
 }}}

 And it will emit a warning!

 {{{
 • Redundant constraint: C a
 • In the instance declaration for ‘C (Identity a)’
 }}}

 This might be even worse that the original example, because now it's
 //GHC// that's providing the redundant constraint, not the programmer.

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


More information about the ghc-tickets mailing list