<br><br><div class="gmail_quote">On Dec 18, 2007 1:00 PM, Cristian Baboi <<a href="mailto:cristian.baboi@gmail.com">cristian.baboi@gmail.com</a>> 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 "understand" so far ...<br><br>Suppose we have these two values:<br>a) \x->x + x<br>b) \x->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->b) -> (a->b)<br>h x = x<br></blockquote><div><br>Of course you can define h. This is just a more specific (as far as types go) version of 'id', as defined in the Prelude:
<br><br> id :: a -> a<br> id x = x<br><br>where 'a' can be any type, including a function such as (a -> b). You can apply 'id' to either of your functions above, and get back an equivalent function, so each of the following evaluates to 20:
<br><br> let f = id (\x -> x+x) in f 10<br> let f = id (\x -> 2 * x) in f 10<br><br></div></div><br>