
17 Nov
2011
17 Nov
'11
11:57 p.m.
2011/11/16 Johan Tibell
On Wed, Nov 16, 2011 at 2:23 PM, Jason Dusek
wrote: Tried a modifySTRef' defined this way:
modifySTRef' ref f = do val <- (f $!!) <$> readSTRef ref writeSTRef ref (val `seq` val)
...but there was no change in memory usage.
Why not just
modifySTRef :: STRef s a -> (a -> a) -> ST s () modifySTRef ref f = do x <- readSTRef ref writeSTRef ref $! f x
(Note that I didn't check if modifySTRef was actually a problem in this case).
I just didn't want to miss an opportunity to put in extra strictness annotations! School of redundancy school. -- Jason Dusek () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments