Michael Hobbs wrote:
>
> Adrian Hey wrote:
> > I've read this paper, and it is good, but I still see no reason to
> > change my opinion regarding referential transparency and IO.
> > But I am terribly confused about this issue, there seems to be no real
> > consensus about this in the FP world. I just can't see how if the
> > result of an action is dependent on unknown external world agents
> > (as it is with the IO monad) it could be described as referentially
> > transparent. I can accept that we have referential transparency for
> > user defined monads, but not the IO monad.
>
> Consider this:
> > type IO a = StateOfUniverse -> (a, StateOfUniverse)
> > -- Not syntactically correct, but you know what I mean.
>
> So anything that is declared, say `IO Int', means that it is actually a
> function that reads in the state of the universe, potentially modifies
> it, and then returns an Int value along with the new state of the
> universe. The interesting thing to note is that the state of the
> universe never changes between calls that are strung together using the
> `>>=' operator. That is, the StateOfUniverse that is returned by the
> first monad is exactly same state that is fed into the second. Whether
> or not you want to call this "referentially transparent", well I guess
> that's up to your own philosophic bias.
I rescind the statement that "the state of the universe never changes
between calls that are strung together using the `>>=' operator". After
further consideration, I believe that that's incorrect.
- Michael Hobbs