<div dir="ltr">On Fri, Sep 6, 2013 at 11:04 AM, Johannes Emerich <span dir="ltr">&lt;<a href="mailto:johannes@emerich.de" target="_blank">johannes@emerich.de</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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></blockquote><div><br></div><div>Coming from another language, where functions aren&#39;t first class, you will probably be used to the notion that a function type is somehow different from any other type. You&#39;ll need to unlearn that for functional languages: function types are just as &quot;real&quot; as (Integer) is, and if I have a type variable somewhere which doesn&#39;t have constraints otherwise preventing it, that type variable can end up being (Integer) or (a -&gt; a) or (Num c =&gt; c -&gt; c -&gt; c) or (Maybe [x]) or (Maybe (a -&gt; a)) or any other (rank-1, i.e. no internal &quot;forall&quot;s) type.</div>
<div><br></div><div>(id) has the type (a -&gt; a); in the use mentioned in the first quoted paragraph, this has unified (a) with (b -&gt; b) to produce (id :: (b -&gt; b) -&gt; (b -&gt; b)) in order for the whole expression to be typeable. In your second example, you don&#39;t have polymorphism &quot;where it&#39;s needed&quot; so it can&#39;t infer a type that will work.</div>
<div><br></div></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</div></div>