[Haskell-cafe] Heavy lift-ing
michael rice
nowgate at yahoo.com
Fri Jul 23 14:43:08 EDT 2010
Hi,
I don't understand what's taking place here.
>From Hoogle:
=================
liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
Promote a function to a monad, scanning the monadic arguments from left to right. For example,
liftM2 (+) [0,1] [0,2] = [0,2,1,3]
liftM2 (+) (Just 1) Nothing = Nothing
=================
What does it mean to "promote a function to a monad?"
It would seem that the monad values must understand the function that's being promoted, like Ints understand (+).
Prelude Control.Monad> liftM2 (+) (Just 1) (Just 1)
Just 2
But how does one add [0,1] and [0,2] to get [0,2,1,3]?
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100723/7ad7de97/attachment.html
More information about the Haskell-Cafe
mailing list