MonadRandom-0.4.1: Random-number generation monad.

Copyright2006-2007 Cale Gibbard, Russell O'Connor, Dan Doel, Remi Turk, Eric Kidd.
LicenseOtherLicense
Stabilityexperimental
Portabilitynon-portable (multi-parameter type classes, undecidable instances)
Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Random.Class

Description

A type class for random number generation monads. See http://www.haskell.org/haskellwiki/NewMonads/MonadRandom for the original version of this code.

Instances of this type class include Rand and monads created using RandT.

Synopsis

Documentation

class Monad m => MonadRandom m where Source

An interface to random number generation monads.

Methods

getRandom :: Random a => m a Source

Return a randomly-selected value of type a. See random for details.

getRandoms :: Random a => m [a] Source

Return an infinite stream of random values of type a. See randoms for details.

getRandomR :: Random a => (a, a) -> m a Source

Return a randomly-selected value of type a in the range [lo,hi]. See randomR for details.

getRandomRs :: Random a => (a, a) -> m [a] Source

Return an infinite stream of randomly-selected value of type a in the range [lo,hi]. See randomRs for details.

Instances

class Monad m => MonadSplit s m | m -> s where Source

An interface to monads with splittable state (as most random number generation monads will have). The intention is that the getSplit action splits the state, returning one half of the result, and setting the new state to the other.

Methods

getSplit :: m s Source

Instances

(Monad m, RandomGen g) => MonadSplit g (RandT g m) Source