RE [Haskell-cafe] Monad Description For Imperative

Dan Piponi dpiponi at
Thu Aug 2 22:55:36 EDT 2007

On 8/2/07, ok <ok at> wrote:
> I asked "How is IO a functor"?

> Please go over this again, but slowly this time.
> Try it... by golly it's true.

I'm not fibbing. I was surprised as you when I found out about this stuff!

> So why *aren't* Monads already set up using the type class machinery
> to always *be* Functors in Haskell?  Isn't it bound to confuse people
> if monads are functors but Monads are not Functors?

I think it's simply an uncorrected mistake in the prelude.

Also, check out Eric Kidd's "lesser known laws" here:
These follow from the category theory. I personally find the
join/return version of the monad laws easier to think about than any
other formulation.

BTW Natural transformations are particularly nice in the category of
types and functions. They're essentially just polymorphic functions of
a certain type. But this means that they're candidates for "Theorems
for Free!"
so they have good properties. So there's a nice little collection of
small but useful theorems about >>=, return, join, fmap and so on that
you can deduce from a small amount of category theory. You can deduce
them all without the category theory, but I find it useful to see
these things in a wider context as they no longer seem like these
random identities that hold for no apparent reason.

I completely agree with you that beginners don't need to know the
category theory. But I highly recommend the first couple of chapters
of your favourite CT textbook (up to natural transformations at least,
and up to adjoints if you can stand it) to Haskellers with a
mathematics background as soon as they are beyond the beginnings. It
really does give a bit of insight into a few areas of Haskell.

(Oh, that Eric Kidd web page will also answer your earlier question
about why Data.Set isn't a Haskell Monad even though the powerset
functor is a monad in the category Set.)

More information about the Haskell-Cafe mailing list