[GHC] #14047: "Illegal instance for type synonym" while deriving Typeable1 for data type

GHC ghc-devs at haskell.org
Fri Jul 28 13:29:03 UTC 2017


#14047: "Illegal instance for type synonym" while deriving Typeable1 for data type
-------------------------------------+-------------------------------------
        Reporter:  alexbiehl         |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #13267            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * os:  Windows => Unknown/Multiple
 * architecture:  x86_64 (amd64) => Unknown/Multiple
 * related:   => #13267


Comment:

 This is expected behavior, see #13267. As it turns out, allowing type
 synonyms to be used as instance heads is extremely tricky to get right,
 and GHC decided to disallow this in 8.2.1 due to incorrect results one
 could achieve with nonsense like:

 {{{
 type ShowF a = Show (a -> Bool)

 instance ShowF Int where
     show _ = "Fun"
 }}}

 As for your particular program, the workaround is simple: just don't
 derive `Typeable`! Every type automatically has `Typeable` instances these
 days, so deriving `Typeable` is a no-op.

 As you've noted `Typeable1` //et al.// have long been deprecated in favor
 of `Typeable`, and given that they're far less useful than they were in
 the past, I propose just removing `Typeable1` and friends altogether.

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


More information about the ghc-tickets mailing list