diff options
author | Joseph C. Sible <josephcsible@users.noreply.github.com> | 2020-03-30 00:10:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-29 21:10:50 -0700 |
commit | 40fd20d43fc2431e411554c138cb6e7d15654917 (patch) | |
tree | 1f9278a9f5467f1effec487ac28e6d00373f8b65 /src/Text/Pandoc | |
parent | c12bf49e596c47ae91ce4d3bdfe320a838beaf31 (diff) | |
download | pandoc-40fd20d43fc2431e411554c138cb6e7d15654917.tar.gz |
Split the RNG so they don't end up equal again after 1 call to next (#6227)
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Class/PandocPure.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Class/PandocPure.hs b/src/Text/Pandoc/Class/PandocPure.hs index 76862248b..23c941839 100644 --- a/src/Text/Pandoc/Class/PandocPure.hs +++ b/src/Text/Pandoc/Class/PandocPure.hs @@ -40,7 +40,7 @@ import Data.Word (Word8) import System.Directory (doesDirectoryExist, getDirectoryContents) import System.FilePath ((</>)) import System.FilePath.Glob (match, compile) -import System.Random (StdGen, next, mkStdGen) +import System.Random (StdGen, split, mkStdGen) import Text.Pandoc.Class.CommonState (CommonState (..)) import Text.Pandoc.Class.PandocMonad import Text.Pandoc.Error @@ -168,10 +168,10 @@ instance PandocMonad PandocPure where getCurrentTimeZone = getsPureState stTimeZone newStdGen = do - g <- getsPureState stStdGen - let (_, nxtGen) = next g - modifyPureState $ \st -> st { stStdGen = nxtGen } - return g + oldGen <- getsPureState stStdGen + let (genToStore, genToReturn) = split oldGen + modifyPureState $ \st -> st { stStdGen = genToStore } + return genToReturn newUniqueHash = do uniqs <- getsPureState stUniqStore |