[Haskell-cafe] One-shot? (was: Global variables and stuff)
Graham Klyne
gk at ninebynine.org
Fri Nov 12 03:29:17 EST 2004
At 16:07 11/11/04 +0000, Keith Wansbrough wrote:
>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.
So you say (and I do agree). But how can I *observe* that they are the same?
#g
--
------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact
More information about the Haskell-Cafe
mailing list