HORIZON HASKELLDocslts/ghc-9.14.x7a6c33e2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 7a6c33e · 2026-10-12

Package1.3.1System

random

Pseudo-random number generation

  • Version1.3.1
  • CategorySystem
  • LicenceBSD-3-Clause
  • Maintainercore-libraries-committee@haskell.org
  • Pinned byhackage random 1.3.1
  • Sourcerandom-1.3.1 on Hackage

Modules

  • System.RandomThis library deals with the common task of pseudo-random number generation.
  • System.Random.StatefulThis library deals with the common task of pseudo-random number generation.
Internal modules · 1

Description

This package provides basic pseudo-random number generation, including the ability to split random number generators.

In pure code, use System.Random.uniform and System.Random.uniformR from System.Random to generate pseudo-random numbers with a pure pseudo-random number generator like System.Random.StdGen.

As an example, here is how you can simulate rolls of a six-sided die using System.Random.uniformR:

See System.Random for more details.

In monadic code, use System.Random.Stateful.uniformM and System.Random.Stateful.uniformRM from System.Random.Stateful to generate pseudo-random numbers with a monadic pseudo-random number generator, or using a monadic adapter.

As an example, here is how you can simulate rolls of a six-sided die using System.Random.Stateful.uniformRM:

The monadic adapter System.Random.Stateful.runStateGen_ is used here to lift the pure pseudo-random number generator pureGen into the System.Random.Stateful.StatefulGen context.

The monadic interface can also be used with existing monadic pseudo-random number generators. In this example, we use the one provided in the mwc-random package:

See System.Random.Stateful for more details.

Depends on

6 packages

Used by in this set · 58