[GHC] #15434: DerivingVia (and perhaps even GND) works badly with DeriveGeneric

GHC ghc-devs at haskell.org
Tue Jul 24 14:32:13 UTC 2018


#15434: DerivingVia (and perhaps even GND) works badly with DeriveGeneric
-------------------------------------+-------------------------------------
        Reporter:  konn              |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by konn):

 > You're explicitly requesting that you reuse the Generic instance for Bad
 Foo, and lo and behold, GHC gives you it.
 I can't imagine the situation where `Generic` should give the different
 information than its true structure.

 Although the code above is simple enough, I think it might be error-prone
 to allow writing Generic in DerivingVia-clause.
 As for GND, deriving strategy `newtype` is used as a prefix for the
 deriving clause, so one can easily notice the mistake;
 but as for DerivingVia, since `via`-clause is placed after constraints,
 one can easily overlook that the current deriving strategy.

 > this code will give an error if combined with the Safe extension

 Hence, I think this behaviour should be enabled by default, even without
 `Safe` extension.

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


More information about the ghc-tickets mailing list