Neil Mitchell wrote:
Hi,

First, its useful to define referential transparency.

In Haskell, if you have a definition

f = not

Then this means that anywhere you see f, you can replace it with not.
For example

"f True" and "not True" are the same, this is referentially transparent.

Now lets define "super show" which takes a function, and prints its
code behind it, so:

superShow f = "not"
superShow g = "\x -> case ..."

now superShow f /= superShow g, so they are no longer referentially transparent.

Hence, you have now broken referential transparency.

So you can't show these two functions differently, so what can you do
instead? You can just give up and show all functions the same

instance Show (a -> b) where
    show x = "<function>"

This is the constant definition of show mentioned.

You can be less restrictive than that.  The show function can give
different results when applied to functions with different types
without breaking anything.

        -- Lennart
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to