Guarantees for ST and IO shared in common?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Guarantees for ST and IO shared in common?

Christopher Allen
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

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

RE: Guarantees for ST and IO shared in common?

Simon Peyton Jones

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:[hidden email]] On Behalf Of Christopher Allen
Sent: 03 February 2016 23:30
To: [hidden email]
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


_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Reply | Threaded
Open this post in threaded view
|

Re: Guarantees for ST and IO shared in common?

Christopher Allen
Perfect, thank you very much Simon! I know you're busy so you taking the time to answer questions like this is a much appreciated gift.

On Thu, Feb 4, 2016 at 6:11 AM, Simon Peyton Jones <[hidden email]> wrote:

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:[hidden email]] On Behalf Of Christopher Allen
Sent: 03 February 2016 23:30
To: [hidden email]
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




--
Chris Allen
Currently working on http://haskellbook.com

_______________________________________________
ghc-devs mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs