Skip to content

Higher-rank kind in datatype definition rejected

Example program:

{-# LANGUAGE TypeInType, KindSignatures, ExplicitForAll #-}
import Data.Kind
data X (a :: forall k. k -> * ) = X

errors with

polykind.hs:3:1: error:
    Expecting one more argument to ‘a’
    Expected kind ‘k0’, but ‘a’ has kind ‘forall k. k -> *’

Without TypeInType, the error is better, yet gives false hint:

polykind.hs:3:23: error:
    Illegal kind: forall k. k -> *
    Did you mean to enable TypeInType?

For the record 7.10.3 doesn't recognise polymorphic kinds at all (same program, without Data.Kind import):

polykind.hs:3:23: parse error on input ‘forall’

Which makes me think that polymorphic kinds are somehow supported, but maybe not.

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