Can strict ST break referential transparency?
david at well-typed.com
Wed Nov 22 20:37:00 UTC 2017
If there is indeed a problem, I suspect the right way to fix it is to make sure that no partially evaluated thunk is ever resumed twice. Inter-thread exceptions are presumably rare enough that we don't have to worry *too* much about their cost.
David FeuerWell-Typed, LLP
-------- Original message --------From: Yuras Shumovich <shumovichy at gmail.com> Date: 11/21/17 12:43 PM (GMT-05:00) To: ghc-devs <ghc-devs at haskell.org> Subject: Can strict ST break referential transparency?
I was evaluating a possibility that linear types can break referential
transparency , exactly like lazy ST .
But on the way I realized that even strict ST may suffer from the same
issue. If ST computation is interrupted by e.g. async exception,
runtime will "freeze" it at the point where it was interrupted .
So the question: is the "freezed" computation just a normal thunk? Note
that the runtime doesn't guarantee that a thunk will be evaluated only
once . If the "freezed" thunk captures e.g. STRef, and will be
evaluated twice, its effect could become observable from outside, just
like in case of lazy ST.
I tried to check the theory by stress testing RTS. Unfortunately I
immediately discovered a runtime crash , which is probably not
related to my question.
Hope someone will be able to clarify things for me.
 See section 8 there: https://www.microsoft.com/en-us/research/wp-co
ghc-devs mailing list
ghc-devs at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs