Sometimes the apply operator $ can be handy for other purposes too, e.g.<div><br></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><span class="Apple-style-span" style="font-weight: bold;"><span class="Apple-style-span" style="font-size: large;">map ($ 1) [cos, sin, tan]</span></span></span></div>
<div><br></div><div>evaluates to</div><div><br></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><span class="Apple-style-span" style="font-weight: bold;"><span class="Apple-style-span" style="font-size: large;">[cos $ 1, sin $ 1, tan $ 1]</span></span></span></div>
<div><br></div><div><div>which just evaluates to</div><div><br></div></div><div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace;"><span class="Apple-style-span" style="font-size: large;"><span class="Apple-style-span" style="font-weight: bold;">[cos 1, sin 1, tan 1]</span></span></span></div>
<div><br></div><div><br></div><div><br></div><div>Note that some consider the following as bad coding&nbsp;style:</div><div><br></div><div>f $ g $ h $ x</div><div><br></div><div>Instead, the following is&nbsp;preferred</div><div><br>
</div><div>f . g . h $ x</div><div><br></div><div class="gmail_quote">On Mon, Feb 23, 2009 at 7:27 PM, Andrew Wagner <span dir="ltr">&lt;<a href="mailto:wagner.andrew@gmail.com">wagner.andrew@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">The $ function is essentialy a &quot;no-op&quot;. That is, it literally does nothing. There is no difference in Haskell between a function and a reference to it. The only purpose of $ is for grouping. The line in question below could have been written identically as &quot;fromQty &lt;- atomically (readTVar fromBal)&quot;. The $ groups together everything to the end of the line, and can be used to avoid parentheses that could add noise to the code.<div>
<div></div><div class="Wj3C7c"><br>
<br><div class="gmail_quote">On Mon, Feb 23, 2009 at 1:18 PM, Michael Easter <span dir="ltr">&lt;<a href="mailto:codetojoy@gmail.com" target="_blank">codetojoy@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>re: desugaring.&nbsp; Thanks Andrew, that worked great! <br><br>I have another, easier question from the same code in RWH:<br><br>bogusTransfer qty fromBal toBal = do<br>&nbsp;&nbsp;&nbsp; fromQty &lt;- atomically $ readTVar fromBal<br>
&nbsp;&nbsp;&nbsp; [snip]<br>

<br>Can someone please explain the ($) function in English? From the type signature, it seems to be an &quot;apply function&quot;, but I can&#39;t quite explain when we use it. Clearly, it is used throughout RWH but I haven&#39;t found a good explanation.<br>


<br>My guess is that it is when we want an &quot;execution&quot; of a function rather than a mere reference to it. Is that accurate?<br><br>thanks again<br>Michael<br><font color="#888888"><br>-- <br>----------------------<br>

Michael Easter<br>
<a href="http://codetojoy.blogspot.com" target="_blank">http://codetojoy.blogspot.com</a>: Putting the thrill back in blog<br><br><a href="http://youtube.com/ocitv" target="_blank">http://youtube.com/ocitv</a> -&gt; Fun people doing serious software engineering<br>



</font></blockquote></div><br>
</div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>