[Haskell-cafe] Composing monads
jules at jellybean.co.uk
Fri Nov 23 04:08:24 EST 2007
> If I have two computations a->IO b
> and b->IO c, can I join them to
> get an a->IO c computation? I imagine
> something like a liftM dot operator.
You've already been shown the >=> operator and how to define it from >>=
by other answers.
Just for variety, here is how you would define it using do notation:
compose :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
compose act act' a = do
b <- act a
More information about the Haskell-Cafe