[Haskell-cafe] ST not strict enough?
ryani.spam at gmail.com
Tue Nov 22 02:20:28 CET 2011
On Fri, Nov 18, 2011 at 4:05 AM, Yves Parès <limestrael at gmail.com> wrote:
> (Sorry for the double mail)
> ...so there is no way to do that inside the function passed to modifySTRef?
> In other words, there is no way to ensure *inside* a function that its
> result will be evaluated strictly?
modifySTRef looks like this (sugared up a bit):
modifySTRef r f = do
x <- readSTRef r
writeSTRef r (f x)
Note that this writes the *thunk* (f x) to the STRef, and there is
absolutely nothing you can do about it. "f" isn't demanded by this
function, let alone "f x".
You can implement your own strict modifySTRef' easily though, as other
people in this thread have shown.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe