Control.Monad.Random.Class

MonadRandom-0.4.2.3: Random-number generation monad.

Copyright | 2006-2007 Cale Gibbard, Russell O'Connor, Dan Doel, Remi Turk, Eric Kidd.
License | OtherLicense
Stability | experimental
Portability | non-portable (multi-parameter type classes, undecidable instances)
Safe Haskell | Safe
Language | Haskell2010

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

- class Monad m => MonadRandom m where
- getRandom :: (MonadRandom m, Random a) => m a
- getRandomR :: (MonadRandom m, Random a) => (a, a) -> m a
- getRandoms :: (MonadRandom m, Random a) => m [a]
- getRandomRs :: (MonadRandom m, Random a) => (a, a) -> m [a]
- class Monad m => MonadSplit s m | m -> s where
- getSplit :: MonadSplit s m => m s

# Documentation

class Monad m => MonadRandom m where #

An interface to random number generation monads.

Minimal complete definition

getRandom, getRandoms, getRandomR, getRandomRs

Methods

getRandom :: Random a => m a #

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

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

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

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

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

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

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

Instances

(Monad m, RandomGen g) => MonadRandom (RandT g m) # |
Methods getRandom :: Random a => RandT g m a # getRandoms :: Random a => RandT g m [a] # getRandomR :: Random a => (a, a) -> RandT g m a # getRandomRs :: Random a => (a, a) -> RandT g m [a] #

getRandom :: (MonadRandom m, Random a) => m a #

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

getRandomR :: (MonadRandom m, Random a) => (a, a) -> m a #

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

getRandoms :: (MonadRandom m, Random a) => m [a] #

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

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

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

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

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.

Minimal complete definition

getSplit

Methods

getSplit :: m s #

Instances

(Monad m, RandomGen g) => MonadSplit g (RandT g m) # |
Methods getSplit :: RandT g m g #

getSplit :: MonadSplit s m => m s #