[Haskell-cafe] Re: Kleisli composition operator

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Sun Aug 3 11:09:46 EDT 2008

On Sun, 2008-08-03 at 14:52 +0000, Roly Perera wrote:
> > I'm obviously missing something basic here but I don't seem to be able to use
> > the >=> operator which is apparently defined in the Prelude and also in
> > Control.Monad.
> Sorry, I wasn't very clear in my original posting.  What I meant to say is that
> the compiler seems to be unable to find a definition of >=>.  I get the message:
> Not in scope: `>=>'
> My understanding is that I shouldn't need to import this at all by default, and
> that importing Control.Monad should also pick it up.

It's not in the Prelude but it is in Control.Monad in base version 3
and later. You're probably using an older GHC which has base version

You can define it locally:

-- | Left-to-right Kleisli composition of monads.
(>=>)       :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
f >=> g     = \x -> f x >>= g


More information about the Haskell-Cafe mailing list