[Haskell-cafe] Heavy lift-ing

michael rice nowgate at yahoo.com
Sat Jul 24 10:42:03 EDT 2010

```Prelude Control.Monad> liftM2 (\a b -> a : b : []) "abc" "123"
["a1","a2","a3","b1","b2","b3","c1","c2","c3"]
Prelude Control.Monad>

Got it!

Thanks to all.

Michael

--- On Sat, 7/24/10, aditya siram <aditya.siram at gmail.com> wrote:

From: aditya siram <aditya.siram at gmail.com>
Subject: Re: [Haskell-cafe] Heavy lift-ing
To: "Max Rabkin" <max.rabkin at gmail.com>
Cc: "haskell-cafe at haskell.org" <haskell-cafe at haskell.org>, "Lennart Augustsson" <lennart.augustsson at gmail.com>
Date: Saturday, July 24, 2010, 10:35 AM

Perhaps I'm being unclear again. All I was trying to say was that:
liftM2 (-) [0,1] [2,3] /= liftM2 (-) [2,3] [0,1]

-deech

On Sat, Jul 24, 2010 at 9:30 AM, Max Rabkin <max.rabkin at gmail.com> wrote:
> On Sat, Jul 24, 2010 at 4:08 PM, aditya siram <aditya.siram at gmail.com> wrote:
>> 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.
>>
>> -deech
>
> No, it's not. The type of liftM2 makes this clear:
>
> liftM2 :: (Monad m) => (a -> b -> r) -> m a -> m b -> m r
>
> The arguments to the function *must* come in the right order, because
> there is no way to match (a) with (m b) or (b) with (m a). Since
> liftM2 is parametrically polymorphic in (a) and (b), it can't behave
> differently in the case where (a = b).
>
> --Max
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100724/f36736a9/attachment.html
```

More information about the Haskell-Cafe mailing list