<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jan 3, 2016 at 1:05 PM, Imants Cekusins <span dir="ltr"><<a href="mailto:imantc@gmail.com" target="_blank">imantc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><p dir="ltr">Here is composition signature:<br></p></span>
<p dir="ltr"><a href="http://hackage.haskell.org/package/base-4.8.1.0/docs/Prelude.html#v:." target="_blank">(.)</a> :: (b -> c) -> (a -> b) -> a -> c</p>
<p dir="ltr">It looks like it is applicable to functions with 1 arg. Sum expects 2 args. I guess this explains why sum can not be passed to f</p></blockquote><div>This isn't accurate, and it's useful to understand why. Every function in Haskell has exactly one argument. Joel touched on this earlier. It's easier to see if you add the implied parentheses to the type signatures:</div><div><br></div><div>    sum :: Num a => a -> (a -> a)</div><div>    f :: (a -> a) -> (a -> a)<br></div><div><br></div><div>To really drive it home, let's play with synonyms.</div><div><br></div><div>    type Endo' a = (a -> a)</div><div><br></div><div>Endo already exists as a newtype in Data.Monoid, thus Endo' here. Now:<br></div><div><br></div><div>    sum :: Num a => a -> Endo' a</div><div>    f :: Endo' a -> Endo' a</div><div><br></div></div></div></div>