Test that runST is not inlined prematurely
[ghc.git] / testsuite / tests / simplCore / should_run / runST.hs
1 import Control.Monad.ST
2 import Data.STRef
3
4 -- Make sure that the realWord# token used by runST (actually by runSTRep) is
5 -- not inlined, which would share the call to `newMutVar#`, and suddenly there
6 -- would be only one MutVar
7
8 main =
9 let f () = runST $ do
10 ref <- newSTRef 0
11 modifySTRef ref (+1)
12 readSTRef ref
13 in print (f () + f ())