<br><br><div class="gmail_quote">On Dec 18, 2007 1:00 PM, Cristian Baboi &lt;<a href="mailto:cristian.baboi@gmail.com">cristian.baboi@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>This is what I &quot;understand&quot; so far ...<br><br>Suppose we have these two values:<br>a) \x-&gt;x + x<br>b) \x-&gt;2 * x<br>Because these to values are equal, all functions definable in Haskell must<br>preserve this.
<br>This is why I am not allowed to define a function like<br><br>h :: (a-&gt;b) -&gt; (a-&gt;b)<br>h x = x<br></blockquote><div><br>Of course you can define h.&nbsp; This is just a more specific (as far as types go) version of &#39;id&#39;, as defined in the Prelude:
<br><br>&nbsp;&nbsp; id :: a -&gt; a<br>&nbsp;&nbsp; id x = x<br><br>where &#39;a&#39; can be any type, including a function such as (a -&gt; b).&nbsp; You can apply &#39;id&#39; to either of your functions above, and get back an equivalent function, so each of the following evaluates to 20:
<br><br>&nbsp;&nbsp;&nbsp; let f = id (\x -&gt; x+x) in f 10<br>&nbsp;&nbsp;&nbsp; let f = id (\x -&gt; 2 * x) in f 10<br><br></div></div><br>