Skip to content

GHC overquantifies matchabilities in data types' kinds when PolyKinds is enabled

If I load this file into GHCi:

{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
module Bug where

import Data.Kind

data T :: Type -> Type

The :info command reveals something strange:

λ> :set -fprint-explicit-matchabilities 
λ> :info T
type role T phantom
type T :: forall {t :: GHC.Types.Matchability}.
          * -> @('GHC.Types.Matchable) *
data T a
        -- Defined at Bug.hs:7:1

Note how the kind of T quantifies t but never uses it. Note that this only happens when PolyKinds is enabled, since disabling that extension will produce a more sensible kind for T:

λ> :info T
type role T phantom
type T :: * -> @('GHC.Types.Matchable) *
data T a
        -- Defined at Bug.hs:7:1