All Monads are Functors

Donald Bruce Stewart dons at
Sun Aug 13 21:39:57 EDT 2006

> I find myself dismayed that the mathematical relationship
> between Monads and Functors isn't available in Haskell98; if
> I use fmap in a Monad m=>... typed function, I get an extra
> Functor m required in the context, but not only are all
> mathematical monads functors, any instance of Monad has fmap
> in the form (>>= return . f), so it's annoying.

For interest. Here's the defn in the Gofer prelude from 1994:
    class Functor f where
        map :: (a -> b) -> (f a -> f b)

    class Functor m => Monad m where
        result    :: a -> m a
        join      :: m (m a) -> m a
        bind      :: m a -> (a -> m b) -> m b

        join x     = bind x id
        x `bind` f = join (map f x)

    class Monad m => Monad0 m where
        zero   :: m a

-- Don

More information about the Haskell-prime mailing list