In this declaration
data Const a = Const Integer
Haskell infers that Const is * -> *. Is it possible to make Const take a type constructor instead, so it will be (* -> *) -> *? Ideally, it should be a -> *, but there are no polymorphic kinds. This thread shows one solution – adding unused constructor. Has the situation changed since 2002?
You’re right, since GHC doesn’t support polymorphic kinds, it will do kind defaulting to
*.However, using the
KindSignaturesextension, you can explicitly annotate a data declaration with a specific kind:Or, if your a fan of GADTs:
You can now write:
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: