[Haskell-cafe] Haskell purity and printing
Nicolas Frisby
nicolas.frisby at gmail.com
Tue Dec 18 16:16:34 EST 2007
Extensionality says that the only observable properties of functions
are the outputs they give for particular inputs. Accepting
extensionality as a Good Thing implies that enabling the user to
define a function that can differentiate between f x = x + x and g x =
2 * x is a Bad Thing.
Note that your h does not differentiate between f and g (in fact, it
does not investigate them at all), the only thing you can do with f,
g, (h f), and (g f) is apply them. Accordingly, it's a fine Haskell
definition.
"Why is extensionality a good thing?" might be a more enlightening
question. My answer would quickly be outshone by others', so I'll stop
here.
On Dec 18, 2007 3:00 PM, Cristian Baboi <cristian.baboi at gmail.com> wrote:
>
> 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list