[Haskell-cafe] Printing and Referential transparency excuse

Yitzchak Gale gale at sefer.org
Tue Dec 25 06:49:21 EST 2007

Hi Cristian,

Cristian Baboi wrote:
> While reading the Haskell language report I noticed that function type is
> not an instance of class Read.
> I was told that one cannot define them as an instance of class Show
> without breaking "referential transparency" or printing a constant...
> How can I define a function to do the inverse operation ?
>    g :: String -> ( a -> b )
> This time I cannot see how referential transparency will deny it.
> What's the excuse now ?
> ...I finished reading the Haskell Language Report and I noticed that the
> class Show and Read are "toys".

Actually, they are not toys at all. They are very useful, and they
do their job well. But it looks like they are not the right tool
for what you want to do.

What exactly are you trying to accomplish? Why would you
want there to be instances like that?

Are you thinking of program development and debugging?
There are great tools for that.

Are you thinking of reflection? There are great tools for that
also. But because of the power of Haskell's type system,
you need that much less than in many other languages.


More information about the Haskell-Cafe mailing list