[Haskell-cafe] Heavy lift-ing

Tilo Wiklund tilo.wiklund at gmail.com
Wed Aug 18 11:12:20 EDT 2010


> I think the point that was being made is that:
>
> liftM2 (flip f) /= flip (liftM2 f)
>
> This is because the former (well: liftM2 (flip f) a b)  effectively does:
>
> do {x <- a; y <- b; return (f y x)}
>
> Whereas the latter (flip (liftM2 f) a b) effectively does:
>
> do {y <- b; x <- a; return (f y x)}
>
> That is, the order of the arguments to liftM2 matters because they are
> executed in that order.  So lifting the flipped function has a different
> effect to flipping the lifted function.
>
> Thanks,
>
> Neil.

Thanks, I can see how that could lead to confusion.


More information about the Haskell-Cafe mailing list