You're right, since GHC doesn't support polymorphic kinds, it will do kind defaulting to *
.
However, using the KindSignatures
extension, you can explicitly annotate a data declaration with a specific kind:
{-# LANGUAGE KindSignatures #-}
data Const (a :: * -> *) = Const Integer
Or, if your a fan of GADTs:
{-# LANGUAGE GADTs #-}
data Const :: (* -> *) -> * where
Const :: Integer -> Const a
You can now write:
x :: Const Maybe
x = Const 2
I just compiled the original program with the experimental Utrecht Haskell Compiler (UHC).
The UHC doesn't really compile any real world programs, but it does support kind polymorphism! Its interesseting to see it infer:
-- kind of data type:
Const :: forall a . a -> *
-- type of constructor:
Const :: Integer -> forall* a . forall b(a) . Const b