Category Theory‎ > ‎

The Kleisli Category

posted Mar 11, 2009, 9:30 PM by Wei Hu
Given the definition,
-- | Left-to-right Kleisli composition of monads.                                                               
(>=>)       :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
f >=> g     = \x -> f x >>= g

The monad laws can be written as
return >=> g == g
g >=> return == g
(g >=> h) >=> k == g>=> (h >=> k)

So, functions of type a -> m b are the arrows of a category with (>=>) as composition, and return as identity.
Comments