class RandomGen g
RandomGen is an interface to pure pseudo-random number generators.
StdGen is the standard RandomGen instance provided by this library.
next :: g -> (Int, g)
No longer used
Returns an Int that is uniformly distributed over the range returned by
genRange (including both end points), and a new generator. Using next
is inefficient as all operations go via Integer. See
[here](https:/alexey.kuleshevi.chblog20191221random-benchmarks) for
more details. It is thus deprecated.
genWord8 :: g -> (Word8, g)
Returns a Word8 that is uniformly distributed over the entire Word8
range.
genWord16 :: g -> (Word16, g)
Returns a Word16 that is uniformly distributed over the entire Word16
range.
genWord32 :: g -> (Word32, g)
Returns a Word32 that is uniformly distributed over the entire Word32
range.
genWord64 :: g -> (Word64, g)
Returns a Word64 that is uniformly distributed over the entire Word64
range.
genWord32R :: Word32 -> g -> (Word32, g)
genWord32R upperBound g returns a Word32 that is uniformly
distributed over the range [0, upperBound].
genWord64R :: Word64 -> g -> (Word64, g)
genWord64R upperBound g returns a Word64 that is uniformly
distributed over the range [0, upperBound].
genShortByteString :: Int -> g -> (ShortByteString, g)
In favor of `System.Random.uniformShortByteString`
Same as `uniformByteArray` `False`, but for `ShortByteString`.
genShortByteString n g returns a ShortByteString of length n filled with
pseudo-random bytes.
Note - This function will be removed from the type class in the next major release as it is no longer needed because of `unsafeUniformFillMutableByteArray`.
unsafeUniformFillMutableByteArray :: MutableByteArray s -> Int -> Int -> g -> ST s g
Fill in the supplied `MutableByteArray` with uniformly generated random bytes. This function is unsafe because it is not required to do any bounds checking. For a safe variant use `System.Random.Sateful.uniformFillMutableByteArrayM` instead.
Default type class implementation uses `defaultUnsafeUniformFillMutableByteArray`.
Mutable array to fill with random bytes
IntOffset into a mutable array from the beginning in number of bytes. Offset must be non-negative, but this will not be checked
IntNumber of randomly generated bytes to write into the array. Number of bytes must be non-negative and less then the total size of the array, minus the offset. This also will be checked.
genRange :: g -> (Int, Int)
No longer used
Yields the range of values returned by next.
It is required that:
If
(a, b) =, thengenRangega < b.genRangemust not examine its argument so the value it returns is determined only by the instance ofRandomGen.
The default definition spans the full range of Int.
split :: g -> (g, g)
In favor of `splitGen`
Returns two distinct pseudo-random number generators.
Implementations should take care to ensure that the resulting generators
are not correlated. Some pseudo-random number generators are not
splittable. In that case, the split implementation should fail with a
descriptive error message.