All Monads are Functors

Ashley Yakeley ashley at
Fri Aug 25 22:09:11 EDT 2006

Jon Fairbairn wrote:

 > There has been discussion in the past about whether Monad
 > should be defined as
 >> class Functor m => Monad m where ...

It's more complicated now that we have Ross Patterson's "Applicative".

The correct decl I think is this:

   class Applicative m => Monad m where
     -- remove "return"

and changing the names of the Applicative functions:

   class Functor f => Applicative f where
     return :: a -> f a
     ap :: f (a -> b) -> f a -> f b

This would mean moving Applicative into the Prelude.

I think "joining up the classes" is a good idea, and there may be other 
cases too. "Alternative" and "MonadPlus"?

Ashley Yakeley

More information about the Haskell-prime mailing list