Skip to content

Deriving fails for type parameterized with unlifted type

Code:

{-# LANGUAGE StandaloneDeriving, MagicHash, DataKinds #-}
module X where

import GHC.Exts

data A = MkA Int
deriving instance Eq A

data B = MkB Int#
deriving instance Eq B

data C a = MkC a
deriving instance Eq (C Int)

data D (a :: TYPE IntRep) = MkD a
deriving instance Eq (D Int#)

The deriving clauses for A, B, C work, but D fails:

X.hs:16:1: error:
    • Can't make a derived instance of ‘Eq (D Int#)’:
        Don't know how to derive ‘Eq’ for type ‘a’

Looks like there's a missing substitution - GHC tries to derive Eq for a, when it's known that a is Int#.

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