[GHC] #9968: DeriveAnyClass fails on multi-parameter type classes

GHC ghc-devs at haskell.org
Wed Dec 9 09:14:19 UTC 2015


#9968: DeriveAnyClass fails on multi-parameter type classes
-------------------------------------+-------------------------------------
        Reporter:  goldfire          |                Owner:  dreixel
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.0.1
       Component:  Compiler          |              Version:  7.10.1-rc1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #9821             |  Differential Rev(s):
-------------------------------------+-------------------------------------

Comment (by Simon Peyton Jones <simonpj@…>):

 In [changeset:"af77089b08b60c00128f0e5a65d18211ea62dfee/ghc" af77089/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="af77089b08b60c00128f0e5a65d18211ea62dfee"
 Fix DeriveAnyClass (Trac #9968)

 The main issue concerned things like

    data T a = MkT a deriving( C Int )

 which is supposed to generate

    instance C Int (T a) where {}

 But the 'Int' argument (called cls_tys in the code) wasn't
 even being passed to inferConstraints and mk_data_eqn, so it
 really had no chance.   DeriveAnyClass came along after this
 code was written!

 Anyway I did quite a bit of tidying up in inferConstraints.

 Also I discovered that this case was not covered at all

    data T a b = MkT a b deriving( Bifunctor )

 What constraints should we generate for the instance context?
 We can deal with classes whose last arg has kind *, like Eq, Ord;
 or (* -> *), like Functor, Traversable.  But we really don't have
 a story for classes whose last arg has kind (* -> * -> *).

 So I augmented checkSideConditions to check for that and give
 a sensible error message.

 ToDo: update the user manual.
 }}}

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


More information about the ghc-tickets mailing list