|
Data.Random.Source.PureMT |
|
|
|
Synopsis |
|
|
|
Documentation |
|
|
Given a mutable reference to a PureMT generator, we can make a
RandomSource usable in any monad in which the reference can be modified.
For example, if x :: TVar PureMT, getRandomWordFromMTRef x can be
used as a RandomSource in IO, STM, or any monad which is an instance
of MonadIO. These functions can also be used to implement additional
RandomSource instances for mutable references to PureMT states.
|
|
|
|
|
|
|
Similarly, getRandomWordFromMTState x can be used in any "state"
monad in the mtl sense whose state is a PureMT 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 (e.g., by
runState . sample :: Distribution d t => d t -> PureMT -> (t, PureMT).
PureMT in the type there can be replaced by StdGen or anything else
satisfying MonadRandom (State s) => s).
|
|
|
|
|
|
Produced by Haddock version 2.4.2 |