On Mon, Feb 9, 2009 at 11:06 AM, Tillmann Rendel <span dir="ltr">&lt;<a href="mailto:rendel@cs.au.dk">rendel@cs.au.dk</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Gregg Reynolds wrote::<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
My original question was motivated by the observation that a human reader of<br>
an expression of the form &quot;e &gt;&gt;= f&quot; , on seeing that f is constant, may pull<br>
the constant value out of f, disregard e and dispense with the application f<br>
e. &nbsp;<br>
</blockquote>
<br></div>
While a human reader may well do that, but it would be correct or wrong depending on the definition of &gt;&gt;=. The same is of course true for compilers. By the way, there is no &quot;application f e&quot;.<br>
</blockquote><div><br>I guess it would help if I got the notation right.&nbsp; My intended meaning was f* e, where * is the Kleisli star.&nbsp; Sorry about that. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
An example where it would be wrong to ignore e:<br>
<br>
 &nbsp;sum ([1, 2] &gt;&gt;= const [21])<br>
<br>
This expression should evaluate to sum [21, 21] = 42, not sum [21] = 21.<br>
</blockquote><div><br>Sigh.&nbsp; I hate it when this happens.&nbsp; Just when I thought I had it figured out, it turns out I&#39;m clueless.&nbsp; This is very enlightening and should definitely be included in any monad tutorial.&nbsp; Actually you don&#39;t even need &quot;sum&quot; and &quot;const&quot; to demo the point,&nbsp; &quot;[1,2] &gt;&gt;= \x -&gt; [21]&quot; evals to &quot;[21, 21]&quot; in ghci.&nbsp; And I have absolutely no idea why.&nbsp; Very mysterious, the Kleisli star.&nbsp; :(<br>
<br>Back to the drawing board!<br><br>-gregg</div></div><br>