random-source-0.3.0.11: Generic basis for random number generators

Safe HaskellNone
LanguageHaskell2010

Data.Random.Source.StdGen

Contents

Description

This module provides functions useful for implementing new MonadRandom and RandomSource instances for state-abstractions containing StdGen values (the pure pseudorandom generator provided by the System.Random module in the "random" package), as well as instances for some common cases.

Synopsis

Documentation

data StdGen #

The standard pseudo-random number generator.

Instances
Eq StdGen 
Instance details

Defined in System.Random.Internal

Methods

(==) :: StdGen -> StdGen -> Bool #

(/=) :: StdGen -> StdGen -> Bool #

Show StdGen 
Instance details

Defined in System.Random.Internal

NFData StdGen 
Instance details

Defined in System.Random.Internal

Methods

rnf :: StdGen -> () #

RandomGen StdGen 
Instance details

Defined in System.Random.Internal

(Monad m, ModifyRef (IORef StdGen) m StdGen) => RandomSource m (IORef StdGen) Source # 
Instance details

Defined in Data.Random.Source.StdGen

(Monad m, ModifyRef (STRef s StdGen) m StdGen) => RandomSource m (STRef s StdGen) Source # 
Instance details

Defined in Data.Random.Source.StdGen

(Monad m1, ModifyRef (Ref m2 StdGen) m1 StdGen) => RandomSource m1 (Ref m2 StdGen) Source # 
Instance details

Defined in Data.Random.Source.StdGen

Monad m => MonadRandom (StateT StdGen m) Source # 
Instance details

Defined in Data.Random.Source.StdGen

Monad m => MonadRandom (StateT StdGen m) Source # 
Instance details

Defined in Data.Random.Source.StdGen

(Monad m, Monoid w) => MonadRandom (RWST r w StdGen m) Source # 
Instance details

Defined in Data.Random.Source.StdGen

(Monad m, Monoid w) => MonadRandom (RWST r w StdGen m) Source # 
Instance details

Defined in Data.Random.Source.StdGen

mkStdGen :: Int -> StdGen #

Constructs a StdGen deterministically.

newStdGen :: MonadIO m => m StdGen #

Applies split to the current global pseudo-random generator, updates it with one of the results, and returns the other.

getRandomPrimFromRandomGenRef :: (Monad m, ModifyRef sr m g, RandomGen g) => sr -> Prim a -> m a Source #

Given a mutable reference to a RandomGen generator, we can make a RandomSource usable in any monad in which the reference can be modified.

See Data.Random.Source.PureMT.getRandomPrimFromMTRef for more detailed usage hints - this function serves exactly the same purpose except for a StdGen generator instead of a PureMT generator.

getRandomPrimFromRandomGenState :: forall g m a. (RandomGen g, MonadState g m) => Prim a -> m a Source #

Similarly, getRandomWordFromRandomGenState x can be used in any "state" monad in the mtl sense whose state is a RandomGen generator. Additionally, the standard mtl state monads have MonadRandom instances which do precisely that, allowing an easy conversion of RVars and other Distribution instances to "pure" random variables.

Again, see Data.Random.Source.PureMT.getRandomPrimFromMTState for more detailed usage hints - this function serves exactly the same purpose except for a StdGen generator instead of a PureMT generator.

Orphan instances

(Monad m, ModifyRef (IORef StdGen) m StdGen) => RandomSource m (IORef StdGen) Source # 
Instance details

(Monad m, ModifyRef (STRef s StdGen) m StdGen) => RandomSource m (STRef s StdGen) Source # 
Instance details

(Monad m1, ModifyRef (Ref m2 StdGen) m1 StdGen) => RandomSource m1 (Ref m2 StdGen) Source # 
Instance details

Monad m => MonadRandom (StateT StdGen m) Source # 
Instance details

Monad m => MonadRandom (StateT StdGen m) Source # 
Instance details

(Monad m, Monoid w) => MonadRandom (RWST r w StdGen m) Source # 
Instance details

(Monad m, Monoid w) => MonadRandom (RWST r w StdGen m) Source # 
Instance details