Check out liftM2. It&#39;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">&lt;<a href="mailto:devriese@cs.tcd.ie">devriese@cs.tcd.ie</a>&gt;</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>
 &nbsp;do x&#39; &lt;- x<br>
 &nbsp; &nbsp; f x&#39;<br>
<br>
as<br>
<br>
 &nbsp;x &gt;&gt;= \x -&gt; f x&#39;<br>
<br>
which is clearly the same as<br>
<br>
 &nbsp;x &gt;&gt;= f<br>
<br>
However, now consider<br>
<br>
 &nbsp;do x&#39; &lt;- x<br>
 &nbsp; &nbsp; y&#39; &lt;- y<br>
 &nbsp; &nbsp; f x&#39; y&#39;<br>
<br>
desugared, this is<br>
<br>
 &nbsp;x &gt;&gt;= \x -&gt; y &gt;&gt;= \y&#39; -&gt; f x&#39; y&#39;<br>
<br>
I can simplify the second half to<br>
<br>
 &nbsp;x &gt;&gt;= \x -&gt; y &gt;&gt;= f x&#39;<br>
<br>
but now we are stuck. I feel it should be possible to write something like<br>
<br>
 &nbsp;x ... y ... f<br>
<br>
or perhaps<br>
<br>
 &nbsp;f ... x ... y<br>
<br>
the best I could come up with was<br>
<br>
 &nbsp;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>