[Haskell] IO == ST RealWorld

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Tue Jan 24 13:40:38 EST 2006

Ross Paterson wrote:
> But IO isn't a state monad: others are concurrently changing the world
> without waiting for my Haskell program to terminate.

I think that closed-world behavior should be treated as a property of runST, 
not of the ST monad operations. Otherwise your IORef = STRef IORegion 
proposal doesn't work either, because e.g.

     myId :: STRef s a -> a -> ST s a
     myId r x = writeSTRef r x >> readSTRef r

doesn't necessarily return its second argument when lifted to IO, in the 
presence of multithreading.

This philosophical objection to IO = ST IORegion has come up before, and I 
think it's approaching the problem exactly backwards. If IO = ST IORegion 
works in practice and is useful in practice, then we ought to be coming up 
with a theory of IO/ST that supports it, not rejecting it on the basis of a 
theory that doesn't support it.

-- Ben

More information about the Haskell mailing list