The explanation given below might be a bit heavy for someone who didn't know much about category theory. For those individuals I'd recommend Phil Wadler's papers:
http://homepages.inf.ed.ac.uk/wadler/topics/monads.html I especially recommend "Monads for Functional Programming", "The Essence of Functional Programming" and "Comprehending Monads". Basically, though, the Haskell implementation _is_ the category theoretic definition of monad, with bind/return used instead of (f)map/join/return as described below. Mike > Date: Thu, 18 Aug 2005 20:39:37 -0400 > From: Cale Gibbard <[EMAIL PROTECTED]> > Cc: haskell-cafe@haskell.org > > On 14/08/05, Carl Marks <[EMAIL PROTECTED]> wrote: > > Is there any text/article which makes precise/rigorous/explicit the > > connection > > between the category theoretic definition of monad with the haskell > > implementation? > > Well, a monad over a category C is an endofunctor T on C, together > with a pair of natural transformations eta: 1 -> T, and mu: T^2 -> T > such that > 1) mu . (mu . T) = mu . (T . mu) > 2) mu . (T . eta) = mu . (eta . T) = id_C > > In Haskell, a monad is an endofunctor on the category of all Haskell > types and Haskell functions between them. Application of the > endofunctor to an object is given by applying a type constructor (the > one which is made an instance of the Monad class). Application of the > endofunctor to a function is carried out by fmap or liftM. The natural > transformation eta is called return, and mu is called join (found in > the Monad library). > > Haskell uses a somewhat different (but equivalent) basis for a monad, > in that it is not map, return, and join which need defining to make a > type an instance of the Monad class, but return and (>>=), called > "bind" or "extend". > > One can define bind in terms of fmap, and join as > x >>= f = join (fmap f x) > > and one can get back join and fmap from return and bind: > join x = x >>= id > fmap f x = x >>= (return . f) > > hope this helps, > - Cale > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
