<div dir="ltr"><div><div><div>The observation that this only applies to functions with a polymorphic return type is key.<br><br></div>  id :: a -&gt; a<br><br></div>This can be instantiated at<br></div><div><br>  id&#39; :: (a-&gt;b) -&gt; (a-&gt;b)<br>
</div><div><div><div><div>  id&#39; :: (a-&gt;b) -&gt; a -&gt; b    -- these are the same<br><br></div><div>What this means is that id is a function with arity-2 whenever the first argument is arity-1, and generally id is a function of arity x+1 where x is the argument arity.  Incidentally, this is exactly the same as the ($) operator.<br>
<br></div><div>John L.<br></div><div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 6, 2013 at 10:04 AM, Johannes Emerich <span dir="ltr">&lt;<a href="mailto:johannes@emerich.de" target="_blank">johannes@emerich.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">As is well known, any binary function f can be turned into an infix operator by surrounding it with backticks:<br>
<br>
    f a b   -- prefix application<br>
    a `f` b -- infix application<br>
<br>
It is then possible to take left and right sections, i.e. partially applying f:<br>
<br>
    (a `f`) -- equivalent to \b -&gt; a `f` b<br>
    (`f` b) -- equivalent to \a -&gt; a `f` b<br>
<br>
This extends relatively naturally to functions of arity greater than two, where usage of a function in infix notation produces a binary operator that returns a function of arity n-2.<br>
<br>
Weirdly, however, infix notation can also be used for unary functions with polymorphic types, as the following ghci session shows:<br>
<br>
   Prelude&gt; :t (`id` 1)<br>
   (`id` 1) :: Num a =&gt; (a -&gt; t) -&gt; t<br>
   Prelude&gt; (`id` 1) (\y -&gt; show y ++ &quot;.what&quot;)<br>
   &quot;1.what&quot;<br>
<br>
Desugaring of an equivalent source file shows that id is applied to the anonymous function, which is then applied to 1.<br>
<br>
The following example of a function that is not polymorphic in its return type behaves closer to what I would have expected: It does not work.<br>
<br>
   Prelude&gt; let z = (\y -&gt; True) :: a -&gt; Bool<br>
   Prelude&gt; :t (`z` True)<br>
<br>
   &lt;interactive&gt;:1:2:<br>
       The operator `z&#39; takes two arguments,<br>
       but its type `a0 -&gt; Bool&#39; has only one<br>
       In the expression: (`z` True)<br>
<br>
What is the purpose/reason for this behaviour?<br>
<br>
Thank you,<br>
--Johannes<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div></div></div></div></div></div></div></div>