
3 Oct
2008
3 Oct
'08
9:15 p.m.
Andrew Coppin wrote:
"ap" generalizes the liftM* functions, so
liftM2 f a b = return f `ap` a `ap` b liftM3 f a b c = return f `ap` a `ap` b `ap` c
and so forth.
Now that at least makes sense. (It's non-obvious that you can use it for this. If it weren't for curried functions, this wouldn't work at all...)
Note that the documentation for ap states:
In many situations, the liftM operations can be replaced by uses of ap, which promotes function application.
return f `ap` x1 `ap` ... `ap` xn
is equivalent to
liftMn f x1 x2 ... xn
Tillmann