[Haskell-cafe] ST not strict enough?

Duncan Coutts duncan.coutts at googlemail.com
Fri Nov 18 15:54:07 CET 2011

On 18 November 2011 13:17, Daniel Fischer
<daniel.is.fischer at googlemail.com> wrote:
> On Friday 18 November 2011, 13:05:06, Yves Parès wrote:
>> ...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?
> Well,
> modifySTRef ref fun = do
>    val <- readSTRef ref
>    writeSTRef ref  (fun val)

But note therefore that you can just:

val <- readSTRef ref
writeSTRef ref  $! fun val

rather than using modifySTRef.


More information about the Haskell-Cafe mailing list