Closed mat8913 closed 4 years ago
Indeed
import Control.Monad
import System.Random.MWC
import Data.STRef
go :: IO ()
go = do
ref <- withSystemRandom $ \_ -> newSTRef (1 :: Int)
(print <=< withSystemRandom) $ const $ do
modifySTRef ref succ
readSTRef ref
(print <=< withSystemRandom) $ const $ do
modifySTRef ref succ
readSTRef ref
I think only way to fix it is to provide versins specifically to ST and deprecate withSystemRandom
For example, it allows STRefs to escape.