I was just playing around a bit with ST
in scalaz and came to the point, where I wanted to use the contents of a traversable type to modify my STRef
. In Haskell I could do that as follows (taken from the Haskell wiki):
sumST :: Num a => [a] -> a
sumST xs = runST $ do
n <- newSTRef 0
forM_ xs $ \x -> do
modifySTRef n (+x)
readSTRef n
Unfortunately I have not been able to find the equivalent for forM_
in scalaz. So the question is, how can I do this with scalaz?