<div dir="ltr"><div>Matt</div><div> </div><div>It is not return, but the bind the one that does the miracle of multiplication. </div><div>By its definition for the list monad, it applies the second term once for each element are in the first term. </div>

<div>So return is called many times. At the end, bind concat all the small lists generated</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/20 Matt Ford <span dir="ltr">&lt;<a href="mailto:matt@dancingfrog.co.uk" target="_blank">matt@dancingfrog.co.uk</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
I thought I&#39;d have a go at destructing<br>
<br>
[1,2] &gt;&gt;= \n -&gt; [3,4] &gt;&gt;= \m -&gt; return (n,m)<br>
<br>
which results in [(1,3)(1,4),(2,3),(2,4)]<br>
<br>
I started by putting brackets in<br>
<br>
([1,2] &gt;&gt;= \n -&gt; [3,4]) &gt;&gt;= \m -&gt; return (n,m)<br>
<br>
This immediately fails when evaluated: I expect it&#39;s something to do<br>
with the n value now not being seen by the final return.<br>
<br>
It seems to me that the return function is doing something more than<br>
it&#39;s definition (return x = [x]).<br>
<br>
If ignore the error introduced by the brackets I have and continue to<br>
simplify I get.<br>
<br>
[3,4,3,4] &gt;&gt;= \m -&gt; return (n,m)<br>
<br>
Now this obviously won&#39;t work as there is no &#39;n&#39; value.  So what&#39;s<br>
happening here? Return seems to be doing way more work than lifting the<br>
result to a list, how does Haskell know to do this?  Why&#39;s it not in the<br>
function definition?  Are lists somehow a special case?<br>
<br>
Any pointers appreciated.<br>
<br>
Cheers,<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Matt<br>
</font></span><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>
<br></blockquote></div><br><br clear="all"><br>-- <br>Alberto.
</div>