creating instances of classes haskell

Based on how c is used, Collection requires something of kind * -> * -> *.

> :k Collection
Collection :: (* -> * -> *) -> Constraint

PairList k v, though, has kind *.

Eq, on the other hand, expects something of kind *, which is exactly what Maybe m is.

> :k Eq
Eq :: * -> Constraint

(Maybe itself has kind * -> *, but applying it to a type variable produces something of kind *.)


The thing you put in the instance head will be substituted for the class variable everywhere. So, if we combine

class Collection c where
    empty :: c key value
    -- and other stuff, too, of course

and

instance Collection (PairList k v)

we get the type

    empty :: (PairList k v) key value

which doesn't make a lot of sense. But if we combine the class declaration with

instance Collection PairList

then we get the type

    empty :: PairList key value

which makes sense just fine.