[Haskell-cafe] Heavy lift-ing
aditya.siram at gmail.com
Sat Jul 24 10:08:03 EDT 2010
I wouldn't-it was a bad example. My only point was that because of the
way (>>=) is implemented for lists the order of the arguments 'a' and
'b' in 'liftM2 f a b' matters.
On Sat, Jul 24, 2010 at 1:37 AM, Lennart Augustsson
<lennart.augustsson at gmail.com> wrote:
> Why would you expect swapped operands to (-) ?
> Sent from my iPad
> On Jul 23, 2010, at 20:12, aditya siram <aditya.siram at gmail.com> wrote:
>> Lists are non-deterministic, but the function taken by liftM2 does not
>> necessarily generate all possible outcomes. In the case of (+) it
>> does, not in the case of (-):
>> liftM2 (-) [0,1] [2,3] => [0-1,0-2,1-2,1-3] => [-2,-3,-1,-2]
>> if all possible cases were generated between the two lists we have to
>> include also:
>> On Fri, Jul 23, 2010 at 3:44 PM, Alex Stangl <alex at stangl.us> wrote:
>>> 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].
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe