On Thu, 7 Oct 1999, Adrian Hey wrote:

> On Thu 07 Oct, Manuel M. T. Chakravarty wrote:
> > Check out the type signatures of the `MVar'-related
> > operations and you will find that they are all nicely
> > encapsulated in the `IO' monad.  
> 
> This is true, but I think the point of contention is does the IO monad
> itself provide referential transparency. My opinion is that even thinking
> in such terms for IO is pretty meaningless. I am aware of various
> attempts to fix up the IO semantics with world models, but none of these
> accurately model the world. How could they?
> 
> So what difference does it make if you regard unpredictablity in the result
> of IO operations as caused by non-deterministic world models or Side
> Effect Goblins? Both theories seem equally valid, and both tell us
> very little about the nature or behaviour of the real world.
> 

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. 

This is analogous to a state monad that you yourself can create using the
subset of haskell that everybody agrees on preserving referential
transparency. You can see the operations you create on your state monad 
as a language embedded in haskell. A program in *that embedded language*
need not be referentially transparant, but that does not affect the
properties of haskell, the host language. So:

Of course the state monad - a construct in haskell - 
preserves referential transparency.

Of course the IO monad - a construct in haskell -
preserves referential transparency. 


One could question whether or not haskell preserves referential
transparency. The reason for this is that when you compile and execute a
haskell program, it does not only evaluate to an IO value - *The program
that the value denotes is actually executed* sort of automagically. 


/Lars L





Reply via email to