toolshed- Utilities used by other packages.

Safe HaskellSafe-Inferred




Dr. Alistair Ward
Utilities related to random-numbers.



randomGens :: RandomGen randomGen => randomGen -> [randomGen]Source

Constructs an infinite list of independent random-generators.

shuffle :: RandomGen randomGen => randomGen -> [a] -> [a]Source

  • Shuffles the specified finite list, using the Fisher-Yates algorithm;
  • The resulting list has the same length and constituents as the original; only the order has changed.
  • The input list is traversed, but the items aren't evaluated.

generateSelection :: RandomGen randomGen => randomGen -> [a] -> [a]Source

  • Generate an infinite list of items, each independently randomly selected from the specified finite list.
  • CAVEAT: because the selections are made non-destructively, duplicates may be returned; cf. shuffle.

generateSelectionFromBounded :: (RandomGen randomGen, Bounded a, Random a) => randomGen -> [a]Source

  • Generate an infinite list of data, each independently selected random instances of the specified bounded type.
  • E.g. (generateSelectionFromBounded fmap System.Random.getStdGen) :: IO [Bool] .

select :: RandomGen randomGen => randomGen -> [a] -> aSource

Return a randomly selected element from the specified list.