[GHC] #10598: DeriveAnyClass and GND don't work well together

GHC ghc-devs at haskell.org
Thu Aug 4 03:18:31 UTC 2016


#10598: DeriveAnyClass and GND don't work well together
-------------------------------------+-------------------------------------
        Reporter:  osa1              |                Owner:  RyanGlScott
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  7.11
      Resolution:                    |             Keywords:  Generics
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D2280
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by oerjan):

 Hm. Commenting on that wiki algorithm:

 * Might it be simpler to treat the bespoke -> newtype optimization as a
 post-step, independent of the rest? Or is it ever important ''not'' to
 apply it? Even for step 1.
 * Is 2(a) missing `Enum`?
 * Why is `Traversable` in 2(b)? I would have thought that the bespoke ->
 newtype optimization would apply to it. I guess there's some technical
 difference.
 * All the examples in 2(c) are listed in a or b, leaving the strange
 impression that it can never be triggered. Although I assume `Functor` and
 `Foldable` belong there. (Which also tells me the last paragraph in my
 previous comment has been taken care of).
 * The phrase "can be successfully used with GeneralizedNewtypeDeriving" is
 needed in 2(c) as well. Should 2(d) apply or not if that check falls? If
 it does then sometimes standard classes ''could'' get anyclassed. If it
 does ''not'', then should the classes fall back to bespoke, at least if
 their extensions are enabled?
 * It seems that `Functor` and `Foldable` never get newtype derived if that
 extension is not enabled, even when it would be safe to do so.

 I think the algorithm can be simplified a bit: remove point 2(c) entirely,
 and say explicitly in point 2(d) that it ''doesn't'' apply to standard
 derivable classes.

 Lastly, while thinking about this, I made a table of the (currently four-
 way) classification of the "standard/bespoke" classes:

 ||= GND equivalence    =||||= No extension                         =||||=
 Extension                =||
 ||= Always             =|| 2(a) || `Eq` `Ord` `Enum` `Ix` `Bounded` ||||
 ||
 ||= Requires check     =||||                                        ||
 2(c) || `Functor` `Foldable` ||
 ||= Never              =|| 2(b) || `Read` `Show`                    ||
 2(b) || `Data` `Generic` `Generic1` `Typeable` `Traversable`(?) `Lift` ||

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


More information about the ghc-tickets mailing list