Guarantees for ST and IO shared in common?

Simon Peyton Jones simonpj at microsoft.com
Thu Feb 4 12:11:14 UTC 2016


that the mechanism for preventing things like reordering operations or spurious sharing is shared in common between ST and IO via State#

Yes. It’s pure data dependency, no more and no less. Operations in both ST and IO take a State# token as input, and produce one as output.  So of course to get the input one, all preceding operations must be done first.  Simple!

Simon

From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Christopher Allen
Sent: 03 February 2016 23:30
To: ghc-devs at haskell.org
Subject: Guarantees for ST and IO shared in common?

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 well.


Thanks again for everyone's time.

--
Chris Allen
Currently working on http://haskellbook.com<https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fhaskellbook.com&data=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c437e21b733ab4fa4895908d32cf1fd68%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=PPVWa%2bCUw8gEWIOVEyJNcOKuGGmZBtfvXg0wsA2jS2Y%3d>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20160204/b430c9f3/attachment.html>


More information about the ghc-devs mailing list