
Graham Klyne wrote:
At 12:27 11/11/04 +0000, Ben Rudiak-Gould wrote: [..]
going to be safe, because it's just not the case that
x = once (newIORef ()) y = x
has the same intended meaning as
x = once (newIORef ()) y = once (newIORef ())
No amount of compiler-specific magic is going to fix this.
Ah, yes, I take the point now.
Isn't this generally the case for any value in the IO monad? (Brushing a murky area of equivalence; the same IO computation used twice may yield different results, so I'm not clear to what extent it is meaningful to say that any IO value is the same as any other, including itself, in any observable sense.)
No. "getChar" is always "the IO operation that reads a character from stdin". You can always substitute one instance of "getChar" for another; you can even say "foo = getChar" and substitute "foo" for every occurrence of "getChar". A value of type IO a is a *computation*; its result may change, but the computation itself cannot. --KW 8-)