[Haskell-cafe] Haskell purity and printing

Cristian Baboi cristian.baboi at gmail.com
Tue Dec 18 16:00:47 EST 2007


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

The reasons are very complicated, but it goes something like this:

- when one put \x->x+x trough the function h, the compiler might change it  
to \x -> 2*x
- when one put \x->2*x trough the function h, the compiler might change it  
to \x -> x + x

And we all know that \x -> 2*x is not the same as \x->x+x and this is the  
reason one cannot define h in Haskell


More information about the Haskell-Cafe mailing list