[GHC] #10819: Can't generate data decls deriving multiparam type classes with TH

GHC ghc-devs at haskell.org
Tue Sep 1 06:25:10 UTC 2015


#10819: Can't generate data decls deriving multiparam type classes with TH
-------------------------------------+-------------------------------------
              Reporter:  spinda      |             Owner:
                  Type:  feature     |            Status:  new
  request                            |
              Priority:  normal      |         Milestone:
             Component:  Template    |           Version:  7.10.2
  Haskell                            |
              Keywords:              |  Operating System:  Unknown/Multiple
          Architecture:              |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
             Test Case:              |        Blocked By:
              Blocking:              |   Related Tickets:
Differential Revisions:              |
-------------------------------------+-------------------------------------
 This applies to both data declarations and (more commonly) newtypes.
 Example:

 {{{
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}

 newtype T a = X { unT :: State Int a } deriving (MonadState Int)
 }}}

 The newtype declaration is impossible to express in Template Haskell's
 AST, as the field for the derived classes is {{{[Name]}}} when it should
 really be {{{Cxt}}}.

 A workaround is to generate a {{{StandaloneDerivD}}} for each derived
 multiparam class, but this requires that the user enable the
 {{{StandaloneDeriving}}} extension which can be unintuitive, especially as
 there's no way (as far as I can tell) to detect whether this extension is
 enabled and report a proper error message if it isn't.

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


More information about the ghc-tickets mailing list