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...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111121/1413cbe4/attachment-0001.htm>