Skip to content

Phantom types break new polykind Typeable with either StandaloneDeriving or AutoDeriveTypeable

This test program, reduced from an attempt to bring ekmett's tagged package to HEAD,

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE AutoDeriveTypeable #-}

newtype Tagged s b = Tagged { unTagged :: b }

results in

GHCi, version 7.7.20130218: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( typeable.hs, interpreted )

typeable.hs:5:1:
    Derived typeable instance must be of form (Typeable Tagged)
    In the stand-alone deriving instance for
      `Data.Typeable.Internal.Typeable Tagged'

This message is also emitted if I replace AutoDeriveTypeable StandaloneDeriving and deriving instance Typeable Tagged.

However, a "deriving (Typeable)" clause on the newtype definition works just fine.

Trac metadata
Trac field Value
Version 7.7
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