Guarantees for ST and IO shared in common?

Christopher Allen cma at
Wed Feb 3 23:30:21 UTC 2016

Underlying ST is: GHC.Prim.State# s -> (# GHC.Prim.State# s, a #)

Underlying IO is: GHC.Prim.State# GHC.Prim.RealWorld
        -> (# GHC.Prim.State# GHC.Prim.RealWorld, a #)

Based on the (very helpful!) conversation I had on the #ghc IRC channel, it
seems to me that the mechanism for preventing things like reordering
operations or spurious sharing is shared in common between ST and IO via
State#. Is this accurate? I believe the exception is how RealWorld is used
w/ IO but we can put that off for this question.

If anyone could confirm this understanding that would be helpful. If anyone
could point out exceptions to this notion, I'd very much appreciate that as

Thanks again for everyone's time.

Chris Allen
Currently working on
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list