> -----Original Message-----
> From: Lars Lundgren [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 08, 1999 3:45 AM
> To: Adrian Hey
> Cc: [EMAIL PROTECTED]
> Subject: Re: OO in Haskell
> 
> ...
> 
> I'm really confused about all the fuzz about The IO monad not 
> providing
> referential transparency. As I understand it, this is really simple.
> 
> A value (IO a) *denotes* a program possibly interacting with 
> the world.
> *That* program is of course not referentially transparent. A haskell
> program generating an (IO a) on the other hand *is* referetially
> transparent. 


Lars is exactly right-- this is the nub of the confusion
floating around.  People are confusing two distinct levels.

If you write a Haskell program that produces a Fortran
program, the Haskell program is referentially transparent (RF),
but the Fortran program (of course) is not.   When you use
the IO Monad, you have a Haskell program that is producing
an IO program.  The latter program happens to be interpreted
by the Haskell runtime system, but that is outside the scope
of Haskell semantics.

This also means that you should be clear about what
RF buys you, and what it doesn't buy you.  If
you have a Haskell program H that produces a Fortran
program F, then referential transparency is a powerful
tool that allows you to transform H into an equivalent Haskell
program H' (that may look very different), that produces
exactly the same Fortran program F.  But referential transparency
in Haskell will give you no help in producing another
Fortran program F' that is equivalent to F.  Getting
back to IO Monads, referential transparency in Haskell will
not help you in transforming a program that reads byte X and
then byte Y of a file into an equivalent program that reads
byte Y and then byte X.

Often, transforming the denoted imperative program is a far
more interesting and useful exercise than transforming the
Haskell program that denotes it.  And to do that, you have
to use the traditional reasoning models on imperative
programs.  There is no magic bullet here.

Nikhil



Reply via email to