[GHC] #1935: deriving typeable and data doesn't work for phantom types

GHC trac at galois.com
Mon Nov 26 20:46:36 EST 2007


#1935: deriving typeable and data doesn't work for phantom types
----------------------+-----------------------------------------------------
 Reporter:  alex      |          Owner:         
     Type:  bug       |         Status:  new    
 Priority:  normal    |      Milestone:  6.8.2  
Component:  Compiler  |        Version:  6.8.1  
 Severity:  normal    |     Resolution:         
 Keywords:            |     Difficulty:  Unknown
 Testcase:            |   Architecture:  Unknown
       Os:  Unknown   |  
----------------------+-----------------------------------------------------
Changes (by igloo):

 * cc: igloo (removed)
  * difficulty:  => Unknown
  * summary:  deriving data doesn't work for phantom types => deriving
              typeable and data doesn't work for phantom
              types

Comment:

 What Alex means is that if you have the module
 {{{
 module Foo where

 import Data.Generics

 data Foo a = Foo
     deriving (Data, Typeable)
 }}}
 then GHC (6.6.1, 6.8.1, the 6.8 branch and the HEAD) says
 {{{
 $ ghc -fglasgow-exts -c b.hs

 b.hs:6:5:
     Could not deduce (Typeable a) from the context ()
       arising from the superclasses of an instance declaration
                    at b.hs:6:5
     Possible fix:
       add (Typeable a) to the context of the instance declaration
     In the instance declaration for `Data (Foo a)'
 $
 }}}
 If you instead have
 {{{
 module Foo where

 import Data.Generics

 data Foo a = Foo
     deriving Data

 instance Typeable (Foo a)
 }}}
 then the module is accepted.

 It seems incredible to me that this hasn't come up before, but it didn't
 work in 6.6.1 either.

 This causes some problems for HAppS, so if it's easy then it would be nice
 to get the fix into 6.8.2.

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


More information about the Glasgow-haskell-bugs mailing list