[Haskell] IO == ST RealWorld

Ross Paterson ross at soi.city.ac.uk
Tue Jan 24 15:37:37 EST 2006


On Tue, Jan 24, 2006 at 06:40:38PM +0000, Ben Rudiak-Gould wrote:
> 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.

Ouch!  Being able to do that kind of reasoning in ST is really important.
I'd rather sacrifice stToIO than lose that.



More information about the Haskell mailing list