<div dir="ltr">Exactly. It is a convenience operator that lets you do:<div><br></div><div>f x $ g y $ h z</div><div><br></div><div>instead of</div><div><br></div><div>f x (g y (h z))</div><div><br></div><div><br></div><div style>
As for whether you should write:</div><div style><br></div><div style>foo = f . g</div><div style><br></div><div style>or</div><div style><br></div><div style>foo x = f $ g x</div><div style><br></div><div style>..go with whichever looks clearest and nicest to you. In most cases where you are just taking one argument and applying some functions to it, it's nice to omit the x. But in more complex cases, it may make your code harder to read and modify. See <a href="http://www.haskell.org/haskellwiki/Pointfree">http://www.haskell.org/haskellwiki/Pointfree</a> (and Problems with "pointless" style.)</div>
<div style><br></div><div style>I personally always use pointfree where I would've required a lambda expression, e.g.:</div><div style><br></div><div style>f (g . h) y</div><div style><br></div><div style>instead of</div>
<div style><br></div><div style>f (\x -> g $ h x) y</div><div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 12, 2013 at 10:23 PM, Emanuel Koczwara <span dir="ltr"><<a href="mailto:poczta@emanuelkoczwara.pl" target="_blank">poczta@emanuelkoczwara.pl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Dnia 2013-02-12, wto o godzinie 22:09 +0100, Martin Drautzburg pisze:<br>
<div class="im">> On Friday, 1. February 2013 23:02:39 Ertugrul Söylemez wrote:<br>
><br>
> > (f . g) x = f (g x)<br>
><br>
><br>
> so (f . g) x = f $ g x<br>
><br>
> right?<br>
><br>
> That looks like the two are pretty interchangeable. When would I prefer one<br>
> over the other?<br>
><br>
><br>
<br>
</div>($) has lower precedence (it was introduced for that reason I belive).<br>
<br>
Prelude> :info ($)<br>
($) :: (a -> b) -> a -> b -- Defined in GHC.Base<br>
infixr 0 $<br>
<br>
Please take a look at:<br>
<a href="http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.6.0.1/Prelude.html#v:-36-" target="_blank">http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.6.0.1/Prelude.html#v:-36-</a><br>
<br>