Hoogle Search
Within LTS Haskell 24.0 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
randomRs :: (Random a, RandomGen g) => (a, a) -> g -> [a]tf-random System.Random.TF.Instances No documentation available.
randoms :: (Random a, RandomGen g) => g -> [a]tf-random System.Random.TF.Instances No documentation available.
randomDouble :: PureMT -> (Double, PureMT)mersenne-random-pure64 System.Random.Mersenne.Pure64 Efficiently yield a new 53-bit precise Double value, and a new generator.
randomInt :: PureMT -> (Int, PureMT)mersenne-random-pure64 System.Random.Mersenne.Pure64 Yield a new Int value from the generator, returning a new generator and that Int. The full 64 bits will be used on a 64 bit machine.
randomInt64 :: PureMT -> (Int64, PureMT)mersenne-random-pure64 System.Random.Mersenne.Pure64 Yield a new Int64 value from the generator, returning a new generator and that Int64.
randomWord :: PureMT -> (Word, PureMT)mersenne-random-pure64 System.Random.Mersenne.Pure64 Yield a new Word value from the generator, returning a new generator and that Word.
randomWord64 :: PureMT -> (Word64, PureMT)mersenne-random-pure64 System.Random.Mersenne.Pure64 Yield a new Word64 value from the generator, returning a new generator and that Word64.
randomIO :: MTRandom a => IO amersenne-random System.Random.Mersenne A variant of random that uses the global random number generator (see System.Random#globalrng). Essentially a convenience function if you're already in IO. Note that there are performance penalties calling randomIO in an inner loop, rather than random applied to a global generator. The cost comes in retrieving the random gen from an IORef, which is non-trivial. Expect a 3x slow down in speed of random generation.
randoms :: MTRandom a => MTGen -> IO [a]mersenne-random System.Random.Mersenne Plural variant of random, producing an infinite list of random values instead of returning a new generator.
getStdRandom :: MonadIO m => (StdGen -> (a, StdGen)) -> m arandom System.Random Uses the supplied function to get a value from the current global random generator, and updates the global generator with the new generator returned by the function. For example, rollDice produces a pseudo-random integer between 1 and 6:
>>> rollDice = getStdRandom (randomR (1, 6)) >>> replicateM 10 (rollDice :: IO Int) [5,6,6,1,1,6,4,2,4,1]
This is an outdated function and it is recommended to switch to its equivalent applyAtomicGen instead, possibly with the globalStdGen if relying on the global state is acceptable.>>> import System.Random.Stateful >>> rollDice = applyAtomicGen (uniformR (1, 6)) globalStdGen >>> replicateM 10 (rollDice :: IO Int) [4,6,1,1,4,4,3,2,1,2]