Skip to content


Subversion checkout URL

You can clone with
Download ZIP


createSystemRandom #22

merged 1 commit into from

3 participants


The use case for this is when it's inconvenient to have to restructure your code to live inside withSystemRandom. I original wrote the attached implementation in my own code and then created this pull request. However, once I looked at the code for withSystemRandom, it looks like it would be safe to reimplement createSystemRandom as:

createSystemRandom :: IO GenIO
createSystemRandom = withSystemRandom (return :: GenIO -> IO GenIO)

If my understanding is correct, I can update this pull request to use that implementation instead.


+1 I wrote similar code on several occasions. And yes function in comment is correct


Go ahead and redo it, and I'll apply it. Thanks.


Pull request updated.

@Shimuuar Shimuuar merged commit ba28737 into bos:master


Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 11, 2013
  1. @snoyberg


    snoyberg authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 0 deletions.
  1. +6 −0 System/Random/MWC.hs
6 System/Random/MWC.hs
@@ -69,6 +69,7 @@ module System.Random.MWC
, create
, initialize
, withSystemRandom
+ , createSystemRandom
-- ** Type helpers
-- $typehelp
@@ -441,6 +442,11 @@ withSystemRandom act = do
warned = unsafePerformIO $ newIORef False
{-# NOINLINE warned #-}
+-- | Seed a PRNG with data from the system's fast source of pseudo-random
+-- numbers. All the caveats of 'withSystemRandom' apply here as well.
+createSystemRandom :: IO GenIO
+createSystemRandom = withSystemRandom (return :: GenIO -> IO GenIO)
-- | Compute the next index into the state pool. This is simply
-- addition modulo 256.
nextIndex :: Integral a => a -> Int
Something went wrong with that request. Please try again.