Rand Monad and Random Class #
This module provides tools for formulating computations guided by randomness and for defining objects that can be created randomly.
Main definitions #
Rand
andRandG
monad for computations guided by randomness;Random
class for objects that can be generated randomly;random
to generate one object;
BoundedRandom
class for objects that can be generated randomly inside a range;randomR
to generate one object inside a range;
IO.runRand
to run a randomized computation inside theIO
monad;
References #
- Similar library in Haskell: https://hackage.haskell.org/package/MonadRandom
Create a new random number generator distinct from the one stored in the state
Instances For
instance
Random.instBoundedRandomULiftInstPreorderULift
{α : Type u}
[Preorder α]
[BoundedRandom α]
:
Computes a Rand α
using the global stdGenRef
as RNG.
Note that:
stdGenRef
is not necessarily properly seeded on program startup as of now and will therefore be deterministic.stdGenRef
is not thread local, hence two threads accessing it at the same time will get the exact same generator.