[Haskell-cafe] Heavy lift-ing
Albert Y. C. Lai
trebla at vex.net
Fri Jul 23 14:58:00 EDT 2010
On 10-07-23 02:43 PM, michael rice wrote:
> liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
> What does it mean to "promote a function to a monad?"
liftM2 f m1 m2 is canned code for
a1 <- m1
a2 <- m2
return (f a1 a2)
for example liftM2 f [s,t] [x,y] is [f s x, f s y, f t x, f t y]
liftM2 (++) getLine getLine reads two lines and concatenates them.
More information about the Haskell-Cafe