blob: f9dbb26064c97777b9ad0293dc691f653d5f1d2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
module Dep02 where
import Control.Monad
import Control.Monad.ST.Lazy
import Data.STRef.Lazy
sumST :: Num a => [a] -> a
sumST xs = runST $ do
n <- newSTRef 0
forM_ xs $ \x -> do
modifySTRef n (+x)
readSTRef n
badST :: ()
badST = runST $ unsafeIOToST $ putStrLn "Hello World"
|