
Haskell Design Patterns
By :

Typeclasses with one type parameter are of kind (* -> *), for example:
class Show a :: * -> * class Maybe a :: * -> *
If we declare an instance of Show
, then the typeclass parameters in the kind signatures need to be aligned, for example, consider:
instance (Show a) => Show (Maybe a) where ...
In order to match the kind of a :: *
in Show a
, we use Maybe'
b instead of Maybe
:
Maybe' b :: * -- instead of Maybe :: (* -> *)
The Monad
type-class is of a higher-order than Show
and Maybe
:
class Monad m :: (* -> *) -> * -- m -> Monad m
The Show
type-class is parameterized over type a :: *
; whereas Monad
is parameterized over the type constructor m :: * -> *
. This can seem like a natural and unsurprising generalization for type-classes, but was in fact an exciting leap forward for Haskell, as described in Hudak et al's History of Haskell:
"The first major, unanticipated development in the type-class story came when Mark...
Change the font size
Change margin width
Change background colour