Harden fixST
[ghc.git] / libraries / base / tests / T15349.hs
1 import Control.Monad.ST.Strict
2 import Control.Monad.Fix
3 import Data.STRef
4
5 foo :: ST s Int
6 foo = do
7 ref <- newSTRef True
8 mfix $ \res -> do
9 x <- readSTRef ref
10 if x
11 then do
12 writeSTRef ref False
13 return $! (res + 5)
14 else return 10
15
16 main :: IO ()
17 main = print $ runST foo