
22 Nov
2007
22 Nov
'07
4:24 p.m.
On Nov 22, 2007 1:22 PM, Jonathan Cast
On 22 Nov 2007, at 10:17 AM, Maurí cio wrote:
Hi,
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.
This is called Kleisli composition, by the way; it's defined as (>=>) in Control.Monad.
jcc
Even if you didn't know about (>=>) (I didn't, actually!), it's not too hard to write yourself: (>=>) :: (Monad m) => (a -> m b) -> (b -> m c) -> (a -> m c) (>=>) f g a = f a >>= g There's no magic, just follow the types. =) -Brent