[GHC] #8599: Deriving in associated data families ignores instance's constraints

GHC ghc-devs at haskell.org
Mon Dec 30 16:05:00 UTC 2013


#8599: Deriving in associated data families ignores instance's constraints
-------------------------------------+------------------------------------
        Reporter:  mojojojo          |            Owner:  goldfire
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Documentation     |          Version:  7.6.3
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------
Changes (by simonpj):

 * owner:   => goldfire


Comment:

 I agree with Richard here.

 The primary goal of allowing you to declare a `type`/`data` family within
 a `class` declaration is to make the link explicit and to remind you if
 you forget to give the instance in an `instance` declaration of the class.
 I also love the duality:
  * in a class declaration you give the type signature for any value
 methods; in the instance you give the actual method.
  * in a class declaration you give the kind signature for any associated
 types; in the instance you give the actual type definitions.

 But really it's not much more than syntactic sugar.  You could equally
 well give the associated type family definitions outside the class, and
 likewise the instances.

 However, as syntactic sugar goes, it's pretty heavy. GHC has a lot of code
 that deals with associated types!

 In any case, that's why I agree with Richard's analysis.  I think it'd be
 a mistake to conflate the context for the class instance declaration with
 the context for a derived equality instance.

 Do clarify the documentation, thank you Richard.

 Simon

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


More information about the ghc-tickets mailing list