Skip to content

Typeable deriving behavior different between data families and associated data types

With AutoDeriveTypeable, data families get a Typeable instance, but associated data types in a class don't (and even standalone deriving doesn't work for them).

λ> data family Foo a
λ> typeRep (Proxy :: Proxy Foo)
Foo
λ> class K a where { data Bar a }
λ> typeRep (Proxy :: Proxy Bar)

<interactive>:6:1:
    No instance for (Typeable Bar) arising from a use of ‘typeRep’
    In the expression: typeRep (Proxy :: Proxy Bar)
    In an equation for ‘it’: it = typeRep (Proxy :: Proxy Bar)
λ> deriving instance Typeable Bar

<interactive>:7: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’
Trac metadata
Trac field Value
Version 7.8.4
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