Portability | non-portable (multi-parameter type classes, undecidable instances) |
---|---|
Stability | experimental |
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 Control.Monad.Random.Rand
and
monads created using Control.Monad.Random.RandT
.
- class Monad m => MonadRandom m where
- getRandom :: Random a => m a
- getRandoms :: Random a => m [a]
- getRandomR :: Random a => (a, a) -> m a
- getRandomRs :: Random a => (a, a) -> m [a]
Documentation
class Monad m => MonadRandom m whereSource
An interface to random number generation monads.
Methods
getRandom :: Random a => m aSource
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 aSource
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
MonadRandom IO | |
RandomGen g => MonadRandom (Rand g) | |
(MonadRandom m, Monoid w) => MonadRandom (WriterT w m) | |
MonadRandom m => MonadRandom (StateT s m) | |
MonadRandom m => MonadRandom (ReaderT r m) | |
(Monad m, RandomGen g) => MonadRandom (RandT g m) |