[Haskell-cafe] Heavy lift-ing
Alex Stangl
alex at stangl.us
Fri Jul 23 16:44:14 EDT 2010
On Fri, Jul 23, 2010 at 11:43:08AM -0700, michael rice wrote:
> 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]?
It depends upon the semantics of the particular monad. List monads
represent nondeterminism. So, for example, [0,1] represents a 0 or
1, and [0,2] represents a 0 or 2.
When you add 0 or 1 to 0 or 2, your possible answers are [0,2,1,3].
Alex
More information about the Haskell-Cafe
mailing list