
18 Dec
2007
18 Dec
'07
4:08 p.m.
On Dec 18, 2007 1:00 PM, Cristian Baboi
This is what I "understand" so far ...
Suppose we have these two values: a) \x->x + x b) \x->2 * x Because these to values are equal, all functions definable in Haskell must preserve this. This is why I am not allowed to define a function like
h :: (a->b) -> (a->b) h x = x
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: id :: a -> a id x = x 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: let f = id (\x -> x+x) in f 10 let f = id (\x -> 2 * x) in f 10