Skip to content

Regression in standalone Data deriving for phantom types

Thise code

{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving, PolyKinds #-}
module M where
import Data.Data
import Data.Typeable

data Phantom t = Phantom
  deriving Typeable
deriving instance Typeable t => Data (Phantom t)

compiles with 7.8.4 but not with 7.10.2. The error is

data.hs:8:1:
    Could not deduce (Typeable Phantom)
      arising from the superclasses of an instance declaration
    from the context (Typeable t)
      bound by the instance declaration at data.hs:8:1-48
    In the instance declaration for ‘Data (Phantom t)’

PolyKinds here is a hack I came up with to make this compile with 7.8 (without it, the code doesn't compile with either version); but ideally, this code should compile whether PolyKinds is enabled or not.

Edited by Feuerbach
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information