random-effin-0.1.0.0: A simple random generator library for effin

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Random

Contents

Synopsis

Documentation

data Rand g a Source

Random number generator

Since 0.1.0.0

Instances

Functor (Rand g) 
Typeable (* -> * -> *) Rand 
type Is (* -> * -> *) Rand f 

Execution

runRand Source

Arguments

:: forall a l g . RandomGen g 
=> g

initial internal random generator

-> Effect (Rand g :+ l) a

Effectect using random numbers

-> Effect l (a, g) 

Run a computation with random numbers

Since 0.1.0.0

evalRand :: RandomGen g => g -> Effect (Rand g :+ l) a -> Effect l a Source

Run a computation with random numbers, discarding the final generator.

Since 0.1.0.0

evalRandIO :: EffectLift IO l => Effect (Rand StdGen :+ l) a -> Effect l a Source

Run a computation with random numbers, discarding the final generator.

Since 0.1.0.0

Generator functions

getRandom :: forall a g l. (Random a, EffectRandom g l) => Effect l a Source

Return a randomly-selected value of type a. See random for details.

Since 0.1.0.0

getRandomR :: forall a g l. (Random a, EffectRandom g l) => (a, a) -> Effect l a Source

Return a randomly-selected value of type a in the range (lo,hi). See randomR for details.

Since 0.1.0.0

getRandoms :: forall a g l. (Random a, EffectRandom g l) => Effect l [a] Source

Return an infinite stream of random values of type a. See randoms for details.

Since 0.1.0.0

getRandomRs :: forall a g l. (Random a, EffectRandom g l) => (a, a) -> Effect l [a] Source

Return an infinite stream of randomly-selected value of type a in the range (lo,hi). See randomRs for details.

Since 0.1.0.0

fromList :: EffectRandom g l => [(a, Rational)] -> Effect l a Source

Sample a random value from a weighted list. The total weight of all elements must not be 0.

Since 0.1.0.0

uniform :: EffectRandom g l => [a] -> Effect l a Source

Sample a value from a uniform distribution of a list of elements.

Since 0.1.0.0

Misc

withSplit :: forall g l a. EffectRandom g l => Effect l a -> Effect l a Source

Split the current generator and execute the given computation with it.

Since 0.1.0.0