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

#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 Keywords: | Operating System: Windows Architecture: x86_64 (amd64) | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------------- This occured to me in `network-ip` package today: {{{#!hs {-# LANGUAGE StandaloneDeriving #-} module Repro where import Data.Typeable (Typeable1) data InetAddr a = InetAddr deriving instance Typeable1 InetAddr }}} Results in GHC complaining with: {{{#!hs repro.hs:7:19: error: * Illegal instance for a type synonym A class instance must be for a class * In the stand-alone deriving instance for `Typeable1 InetAddr' | 7 | deriving instance Typeable1 InetAddr | ^^^^^^^^^^^^^^^^^^ }}} This is due to `Typeable1` defined as type synonym for `Typeable` (see here http://hackage.haskell.org/package/base-4.10.0.0/docs/Data- Typeable.html#t:Typeable1). I can see it is deprecated but I would still expect it to work correctly still. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14047 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: Windows | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Description changed by alexbiehl: Old description:
This occured to me in `network-ip` package today:
{{{#!hs {-# LANGUAGE StandaloneDeriving #-} module Repro where
import Data.Typeable (Typeable1)
data InetAddr a = InetAddr deriving instance Typeable1 InetAddr }}}
Results in GHC complaining with:
{{{#!hs repro.hs:7:19: error: * Illegal instance for a type synonym A class instance must be for a class * In the stand-alone deriving instance for `Typeable1 InetAddr' | 7 | deriving instance Typeable1 InetAddr | ^^^^^^^^^^^^^^^^^^ }}}
This is due to `Typeable1` defined as type synonym for `Typeable` (see here http://hackage.haskell.org/package/base-4.10.0.0/docs/Data- Typeable.html#t:Typeable1).
I can see it is deprecated but I would still expect it to work correctly still.
New description: This occured to me in `network-ip` package today: {{{#!hs {-# LANGUAGE StandaloneDeriving #-} module Repro where import Data.Typeable (Typeable1) data InetAddr a = InetAddr deriving instance Typeable1 InetAddr }}} Results in GHC complaining with: {{{#!hs repro.hs:7:19: error: * Illegal instance for a type synonym A class instance must be for a class * In the stand-alone deriving instance for `Typeable1 InetAddr' | 7 | deriving instance Typeable1 InetAddr | ^^^^^^^^^^^^^^^^^^ }}} This is due to `Typeable1` defined as type synonym for `Typeable` (see here http://hackage.haskell.org/package/base-4.10.0.0/docs/Data- Typeable.html#t:Typeable1). I see it is deprecated but I would still expect it to work correctly still. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14047#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: Windows | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by alexbiehl): I should mention this actually worked with ghc-8.0.2 as it also uses a type synonym for `Typeable1`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14047#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#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: | -------------------------------------+------------------------------------- Comment (by alexbiehl): Thank you Ryan. I will PR said package. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14047#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14047: "Illegal instance for type synonym" while deriving Typeable1 for data type -------------------------------------+------------------------------------- Reporter: alexbiehl | Owner: (none) Type: bug | Status: patch 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): Phab:D3817 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3817 Comment: I've submitted Phab:D3817 to remove `Typeable{1..7}`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14047#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14047: "Illegal instance for type synonym" while deriving Typeable1 for data type
-------------------------------------+-------------------------------------
Reporter: alexbiehl | Owner: (none)
Type: bug | Status: patch
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): Phab:D3817
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#14047: "Illegal instance for type synonym" while deriving Typeable1 for data type -------------------------------------+------------------------------------- Reporter: alexbiehl | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.2.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #13267 | Differential Rev(s): Phab:D3817 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * resolution: => fixed * milestone: => 8.4.1 Comment: This is now "fixed", since `Typeable1` no longer exists. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14047#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC