MonadRandomLazy-0.1.1: Lazy monad for psuedo random-number generation.

Portabilitynon-portable (multi-parameter type classes, undecidable instances)
Safe HaskellSafe
LanguageHaskell98

Control.Monad.LazyRandom

Description

License : BSD3

A lazy monad for random-number generation. This monad allows, for example, computation of infinite random lists.

This monad respects the interface defined by MonadRandom.

A monadic computation is one that consumes random values. The bind operation works like the Gen monad in QuickCheck: it does not thread the random seed; instead it *splits* the random seed.

Synopsis

Documentation

evalRand :: RandomGen g => Rand g a -> g -> a Source #

Evaluate a random computation using the generator g. The new g is discarded.

runRand :: RandomGen g => Rand g a -> g -> (a, g) Source #

Run a random computation using the generator g, returning the result and a new generator.

evalRandIO :: Rand StdGen a -> IO a Source #

Evaluate a random computation in the IO monad, using the random number generator supplied by getStdRandom.

data Rand g a Source #

Instances

RandomGen g => MonadSplit g (Rand g) Source # 

Methods

getSplit :: Rand g g #

RandomGen g => Monad (Rand g) Source # 

Methods

(>>=) :: Rand g a -> (a -> Rand g b) -> Rand g b #

(>>) :: Rand g a -> Rand g b -> Rand g b #

return :: a -> Rand g a #

fail :: String -> Rand g a #

Functor (Rand g) Source #

A value of type 'Rand g a' is a monadic computation which, when run, consumes random values from an applicative random-number generator of type g and produces a result of type a.

Methods

fmap :: (a -> b) -> Rand g a -> Rand g b #

(<$) :: a -> Rand g b -> Rand g a #

RandomGen g => Applicative (Rand g) Source # 

Methods

pure :: a -> Rand g a #

(<*>) :: Rand g (a -> b) -> Rand g a -> Rand g b #

(*>) :: Rand g a -> Rand g b -> Rand g b #

(<*) :: Rand g a -> Rand g b -> Rand g a #

RandomGen g => MonadRandom (Rand g) Source # 

Methods

getRandom :: Random a => Rand g a #

getRandoms :: Random a => Rand g [a] #

getRandomR :: Random a => (a, a) -> Rand g a #

getRandomRs :: Random a => (a, a) -> Rand g [a] #