[GHC] #13065: Prohibit user-defined Generic and Generic1 instances

GHC ghc-devs at haskell.org
Sun Jan 8 00:23:46 UTC 2017


#13065: Prohibit user-defined Generic and Generic1 instances
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:  Generics
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Other             |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 GHC isn't able to derive `Generic` instances for GADTs since as it stands
 today, there's no sensible way to do it. The ones you hand-defined are
 bogus, since they would have you believe that there's //two// separate
 datatypes named `Foo`, each with different constructors. And then there's
 the separate issue that they don't capture the `'True` and `'False`
 existential equality information.

 I don't see what pattern synonyms change here. The issue is fundamentally
 about what promises `Generic` instances make, and if we want them to be
 honest, then we cannot allow hand-defined `Generic` instances at all, even
 if they might be temptingly convenient. `GHC.Generics` is a feature which
 necessarily mirrors the definition of datatype, so if a datatype's
 internal structure changes, then its `Generic` instance must change too.
 Full stop.

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


More information about the ghc-tickets mailing list