[Haskell-cafe] DataKinds + KindSignatures question

Karl Voelker karl at karlv.net
Thu Nov 27 04:08:53 UTC 2014


On Wed, Nov 26, 2014, at 01:17 PM, Wojtek Narczyński wrote:
>  > dk.hs:9:17:
>  >     Expected a type, but ‘cmd’ has kind ‘CmdKind’
>  >     In the type ‘cmd -> ByteString’
>  >     In the class declaration for ‘Serialize’
> 

The error message says that it expected a type. That might be a bit
confusing. What it means by "type" is "a thing with kind *". That is the
kind of types, and those types are the only things which have values.
The argument to a function must be a value, so the argument to the "->"
operator must be a type.

Another example to consider which might make this more clear:

Prelude> let { f :: Maybe -> a; f x = undefined }

<interactive>:2:12:
    Expecting one more argument to ‘Maybe’
    Expected a type, but ‘Maybe’ has kind ‘* -> *’
    In the type signature for ‘f’: f :: Maybe -> a

Notice that in the type signature for f, I forgot to apply Maybe to an
argument. On its own, Maybe has kind * -> *, which means that Maybe is
not a type. After all, there is no such thing as a "value of type
Maybe".

> Is this so by design, or should I write it in a different way, or is it 
> just not implemented?

I don't think it's clear what you are trying to do, so it is hard to say
what you should write.

-Karl


More information about the Haskell-Cafe mailing list