blob: 5ee1cd028802c455a98b9bbeb6aca36370439a0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
module Dep01 where
import Control.Monad
import Control.Monad.ST
import Data.STRef
sumST :: Num a => [a] -> IO a
sumST xs = unsafeSTToIO $ do
n <- newSTRef 0
forM_ xs $ \x -> do
modifySTRef n (+x)
readSTRef n
|