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

Safe HaskellNone
LanguageHaskell2010

Data.Random.Source.RandomGen

Contents

Description

This module provides functions useful for implementing new MonadRandom and RandomSource instances for state-abstractions containing over RandomGen instance (the type class for pseudorandom generators provided by the System.Random module in the "random" package), as well as instances for some common cases.

Synopsis

Documentation

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.

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.

Orphan instances

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

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

(RandomGen g, Monad m) => MonadRandom (StateT g m) Source # 
Instance details

(RandomGen g, Monad m) => MonadRandom (StateT g m) Source # 
Instance details

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

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