Check out liftM2. It's almost what you want.<br><br><div class="gmail_quote">On Thu, Feb 12, 2009 at 6:36 PM, Edsko de Vries <span dir="ltr"><<a href="mailto:devriese@cs.tcd.ie">devriese@cs.tcd.ie</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
I can desugar<br>
<br>
do x' <- x<br>
f x'<br>
<br>
as<br>
<br>
x >>= \x -> f x'<br>
<br>
which is clearly the same as<br>
<br>
x >>= f<br>
<br>
However, now consider<br>
<br>
do x' <- x<br>
y' <- y<br>
f x' y'<br>
<br>
desugared, this is<br>
<br>
x >>= \x -> y >>= \y' -> f x' y'<br>
<br>
I can simplify the second half to<br>
<br>
x >>= \x -> y >>= f x'<br>
<br>
but now we are stuck. I feel it should be possible to write something like<br>
<br>
x ... y ... f<br>
<br>
or perhaps<br>
<br>
f ... x ... y<br>
<br>
the best I could come up with was<br>
<br>
join $ return f `ap` x `ap` y<br>
<br>
which is not terrible but quite as easy as I feel this should be. Any hints?<br>
<br>
Edsko<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>