13 Aug
2002
13 Aug
'02
10:31 a.m.
I can't seem to figure out what the difference is between using
evaluate (runST action)
and
stToIO action
when in the IO monad and running something in ST...they seem to behave identically...are they?
If they are, why do they have different type signatures (one is ST RealWorld a -> IO a, while the other is (forall s. ST s a) -> IO a)?
With stToIO, you can do this: do r <- stToIO newSTRef stToIO $ writeSTRef r 42 ... the types prevent you doing that with runST, but runST is safe to use in pure code whereas stToIO must be used in the IO monad. Cheers, Simon