Skip to content

Deriving Typeable for data families

Bas points out that deriving Typeable for data families isn't right at all.

{-# LANGUAGE DeriveDataTypeable, TypeFamilies #-}

import Data.Typeable

class C a where
    data T a :: *

instance C Int where
    data T Int = A1 deriving (Typeable)

instance C Bool where
    data T Bool = A2 deriving (Typeable)

gives this error:

TF_Data.hs:12:34:
    Duplicate instance declarations:
      instance Typeable1 T -- Defined at TF_Data.hs:12:34
      instance Typeable1 T -- Defined at TF_Data.hs:15:34

The real problem is that we should have only one instance for Typeable T. We should only allow

deriving instance Typeable1 T

and prohibit deriving Typeable on data instance declarations.

Trac metadata
Trac field Value
Version 7.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information