On Thu, Sep 2, 2010 at 10:45 AM, michael rice <span dir="ltr">&lt;<a href="mailto:nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;</span> wrote:<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit"><div class="im"><br>Can you think of a situation for<br><br> \x -&gt; f x<br></div>or<br> \x y z -&gt; x + ord y - head z<br>
<br>that would require x (y z) to have their type(s) declared (ala Pascal), or is it always<br>inferred by what appears to the right of &quot;-&gt;&quot;?<br></td></tr></tbody></table></blockquote><div><br></div><div>I think Haskell 98 can always infer the type of an anonymous function. There are some extensions involving more advanced types that can&#39;t be inferred, but you don&#39;t need to worry about them yet.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">I guess what I&#39;m asking is can an anonymous function be given a type signature?</td>
</tr></tbody></table></blockquote><div><br></div><div>Sure. Just write (\x -&gt; x + 1) :: Int -&gt; Int. (The parentheses are important. Without them, the type signature is given to the function body.)</div><div><br></div>
<div>I don&#39;t think I&#39;ve ever needed to give a type for an anonymous function, though. Generally, the context where the function is being used is sufficient. </div></div><br>-- <br>Dave Menendez &lt;<a href="mailto:dave@zednenem.com">dave@zednenem.com</a>&gt;<br>
&lt;<a href="http://www.eyrie.org/~zednenem/">http://www.eyrie.org/~zednenem/</a>&gt;<br>