[Haskell-cafe] beginner's problam with a monad

Keegan McAllister keegan at caltech.edu
Sun Sep 3 14:31:19 EDT 2006

> Now if anyone could enlighten me about the "instance Monad Tracker a"
> instead of "instance Monad Tracker" part, everything will be clear!

A Monad always takes one type argument -- the a in IO a, Maybe a, etc. 
So Tracker can't be a Monad (it needs two arguments), but (Tracker a) 
is, for any a.  This is basically partial application at the type level.

Formally, we say a Monad needs to have "kind" * -> *.  Kinds are like 
types for the type level.  A kind of * indicates an actual type which 
can have values, etc.  A kind of k1 -> k2 indicates a type operator 
which wants as an argument a type of kind k1, and will produce a type of 
kind k2.  As with types, the kind arrow is right-associative and partial 
application is allowed.

We can see the mismatch in the following (hypothetical) GHCi session:

Prelude> :info Monad
class Monad (m::* -> *) where
Prelude> :kind Tracker
Tracker :: * -> * -> *
Prelude> :kind Tracker Bool
Tracker Bool :: * -> *

Hope that helps,

More information about the Haskell-Cafe mailing list