When I define
data Foo a = Foo [a]
then the type is of kind Foo :: * -> *.
Having enabled PolyKinds and RankNTypes I'd like to explicitly quantify it with a more general kind signature Foo :: forall k . k -> k.
However none of my attempts worked:
-- Malformed head of type or class declaration: (Foo :: forall k.
-- k -> k) a
32 | data (Foo :: forall k . k -> k) a = Foo [a]
-- error: parse error on input ‘::’
32 | data Foo a = Foo [a] :: forall k . k -> k
-- error:
-- Multiple declarations of ‘Foo’
data Foo :: forall k . k -> k
data Foo a = Foo [a]
You can use a standalone kind signature:
But do note that the kind
forall k. k -> kis not valid forFoo, becauseFoo a, being a data type, must have kindType, furthermore the kind of[]isType -> Type. So the kind signatureFoo :: Type -> Typeis forced.An example that does compile without errors is: