I know the s
of ST S a
can’t escape from the ST
Monad, unless it’s s ~ RealWord
. You can then run it as IO
using stToIO
. So for example one can (in ghci)
:m + Control.Monad.ST Data.STRef
ref <- stToIO $ newSTRef (1 :: Int)
stToIO $ modifySTRef ref (+1)
stToIO $ readSTRef ref
>> 2
So is STRef RealdWorld
and IORef
equivalent or I am missing something ?