In Scala(Z), the obvious higher-kind type is the MonadTrans
trait:
trait MonadTrans[F[_ [_], _]] { ... }
Its kind is T->*
, where T
is the kind of its parameter F
.
F
is a monad transformer, and T
is the kind of all monad transformers. Recall that a monad transformer is parametrised by a monad and its "output" is another monad, so its kind is (*->*) -> (*->*)
(or, equivalently, (*->*) -> * -> *
). So the kind of MonadTrans
is
((*->*) -> * -> *) -> *
In Haskell there are no traits, and type classes are not types, so MonadTrans
is out as a non-type. There is a type that represents a composition of monad transformers though:
newtype ComposeT f g m a = ...
Here's its full definition from Control.Monad.Trans.Compose
:
newtype ComposeT (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *) m a
= ComposeT { getComposeT :: f (g m) a }
Quite a mouthful! f
and g
are monad transformers (as can be seen from their explicitly given signatures), m
is a monad (signature * ->*
is not given explicitly but implied by g m
), and a
is a regular type of kind *
. So the overall kind of ComposeT
is:
((* -> *) -> * -> *) ->
((* -> *) -> * -> *) ->
(* -> *) -> * -> *