The $ function is essentialy a "no-op". 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 "fromQty <- atomically (readTVar fromBal)". The $ groups together everything to the end of the line, and can be used to avoid parentheses that could add noise to the code.<br>
<br><div class="gmail_quote">On Mon, Feb 23, 2009 at 1:18 PM, Michael Easter <span dir="ltr"><<a href="mailto:codetojoy@gmail.com">codetojoy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>re: desugaring. 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> fromQty <- atomically $ readTVar fromBal<br> [snip]<br>
<br>Can someone please explain the ($) function in English? From the type signature, it seems to be an "apply function", but I can't quite explain when we use it. Clearly, it is used throughout RWH but I haven't found a good explanation.<br>
<br>My guess is that it is when we want an "execution" 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> -> Fun people doing serious software engineering<br>
</font></blockquote></div><br>