On Fri, Nov 18, 2011 at 4:05 AM, Yves Parès <limestr...@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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to