summaryrefslogtreecommitdiff
path: root/libraries/base/tests/T15349.hs
blob: 6674330924e4f7a4c36f3adad801aaf59d73fd63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import Control.Monad.ST.Strict
import Control.Monad.Fix
import Data.STRef

foo :: ST s Int
foo = do
  ref <- newSTRef True
  mfix $ \res -> do
    x <- readSTRef ref
    if x
      then do
        writeSTRef ref False
        return $! (res + 5)
      else return 10

main :: IO ()
main = print $ runST foo