rng-utils-0.3.1: RNG within an IORef for convenient concurrent use

CopyrightSoostone Inc Snap Framework Authors
LicenseBSD3
MaintainerOzgun Ataman <ozgun.ataman@soostone.com>
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Data.RNG

Contents

Description

Convenience thread-safe wrapper around mwc-random library for practical supply of random numbers in a concurrent environment.

Synopsis

Documentation

data RNG Source #

Mutable random number generator state

mkRNG :: IO RNG Source #

Create a new RNG in the IO monad using newStdGen. Splits the global random number generator, so 2 calls to mkRNG will produce different RNGs.

seedRNG :: Int -> IO RNG Source #

Create a new RNG with a user-specified seed.

packRNG :: StdGen -> IO RNG Source #

Pack your own rng into the RNG type.

withRNG :: RNG -> (StdGen -> (a, StdGen)) -> IO a Source #

Perform given action, mutating the RNG state underneath.

randomToken :: Int -> RNG -> IO ByteString Source #

Generates a random salt of given length

rngRIO :: Random a => RNG -> (a, a) -> IO a Source #

Generate a random value from a range.

rngIO :: Random a => RNG -> IO a Source #

Generate a random value.

Re-export Random for convenience.