[GHC] #9205: Deriving Typeable for poly-kinded data family gives confusing error message

GHC ghc-devs at haskell.org
Sat Jun 14 20:05:10 UTC 2014


#9205: Deriving Typeable for poly-kinded data family gives confusing error message
------------------------------------+-------------------------------------
       Reporter:  dfranke           |             Owner:
           Type:  bug               |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:  7.8.2
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 The following works fine:

 {{{
 {-# LANGUAGE TypeFamilies, DeriveDataTypeable, StandaloneDeriving #-}
 module Test where

 import Data.Typeable

 class Foo a where
   data family Bar a

 deriving instance (Typeable Bar)
 }}}

 However, if I add `-XPolyKinds`, I get a horribly confusing error:

 {{{
 Test.hs:9:1:
     Can't make a derived instance of ‘Typeable Bar’:
       Deriving Typeable is not allowed for family instances;
       derive Typeable for ‘Bar’ alone
     In the stand-alone deriving instance for ‘Typeable Bar’
 }}}

 The correct way to resolve the error is to add a monomorphic kind
 signature to Bar, e.g. `data family Bar (a :: *)`. Perhaps the error
 message could suggest this?

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


More information about the ghc-tickets mailing list