Pure functions for random number generation.

- data Seed
- seed :: [Word32] -> Seed
- class Bounded x => BoundedRandom x where
- bounded_random :: Seed -> (x, Seed)

- class Ord x => UnitRandom x where
- unit_random :: Seed -> (x, Seed)

- class Ord x => RangeRandom x where
- range_random :: (x, x) -> Seed -> (x, Seed)

- random_list :: (Seed -> (x, Seed)) -> Int -> Seed -> ([x], Seed)

# Random seed

seed :: [Word32] -> SeedSource

Create a new random seed value from the supplied list of `Word32`

values. If the list is empty, return a default, hard-coded value.
Otherwise, every element of the list affects the result. The list
*must* be finite; the function will loop forever othewise.

# Random number generation

class Bounded x => BoundedRandom x whereSource

Class of things that can be chosen at random over their entire value range. This requires that the range of possible values is actually limited.

bounded_random :: Seed -> (x, Seed)Source

class Ord x => UnitRandom x whereSource

Class of things that can be chosen at random over the interval from
zero to one. This requires that "zero" and "one" are meaningful
concepts for this type, and also that the type is ordered. (Also,
there must be values *between* zero and one, which rules out
integral types.)

unit_random :: Seed -> (x, Seed)Source

class Ord x => RangeRandom x whereSource

Class of things that can be chosen at random over a specified interval. This requires that the type is ordered.

range_random :: (x, x) -> Seed -> (x, Seed)Source

Given a `Seed`

, return a randomly-chosen value and a new `Seed`

value.

The value is chosen psuedo-randomly (the same `Seed`

will always
yield the same choice), with uniform distribution (all values
equally likely). The range is given by the first argument, which
specifies the lower and upper bounds (inclusive).