On Tuesday 12 Oct 2004 10:19 pm, Jules Bean wrote:
> It does matter for general IO operations at the top level.
All I'm aiming for is to disambiguate programs (avoid the use of
unsafePerformIO) in such a way that the programmer at least stands a
reasonable chance of getting it right without compiler optimisations
screwing things up.
> Order
> doesn't matter in in any essential way for the particular case of
> newIORef, no.
Or for a great many other IO operations that a programmer may wish
to use, though certainly not all that he could define (if sufficiently
malicious :-)
> Now it's my turn not to understand you. What is a "thing with identity"?
Basically I mean some packet of state, where is makes a difference
which particular packet of state is referenced.
So an IORef is a reference to a "thing with identity".
Of course this is why the type of newIORef is..
newIORef :: a -> IO (IORef a)
not simply..
newIORef :: a -> IORef a
Any new "thing with identity" has be constructed via something like..
newThing :: IO Thing
..which makes it difficult to create such things at the top level, even
though (as Simon M pointed out) there's no problem with actually using
such things at the top level (assuming we had some magic that enabled
their creation).
Regards
--
Adrian Hey