Portability | non-portable (multi-parameter type classes, undecidable instances) |
---|---|
Stability | experimental |
Safe Haskell | Safe-Inferred |
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
.
- 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]
- class Monad m => MonadSplit s m | m -> s where
- getSplit :: m s
Documentation
class Monad m => MonadRandom m whereSource
An interface to random number generation monads.
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.
MonadRandom IO | |
MonadRandom m => MonadRandom (IdentityT m) | |
MonadRandom m => MonadRandom (MaybeT m) | |
RandomGen g => MonadRandom (Rand g) | |
MonadRandom m => MonadRandom (ContT r m) | |
(Error e, MonadRandom m) => MonadRandom (ErrorT e m) | |
MonadRandom m => MonadRandom (ReaderT r m) | |
MonadRandom m => MonadRandom (StateT s m) | |
(MonadRandom m, Monoid w) => MonadRandom (WriterT w m) | |
(Monad m, RandomGen g) => MonadRandom (RandT g m) |
class Monad m => MonadSplit s m | m -> s whereSource
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.
MonadSplit StdGen IO | |
RandomGen g => MonadSplit g (Rand g) | |
MonadSplit g m => MonadSplit g (MaybeT m) | |
MonadSplit g m => MonadSplit g (IdentityT m) | |
MonadSplit g m => MonadSplit g (ContT r m) | |
(Error e, MonadSplit g m) => MonadSplit g (ErrorT e m) | |
MonadSplit g m => MonadSplit g (ReaderT r m) | |
(MonadSplit g m, Monoid w) => MonadSplit g (WriterT w m) | |
MonadSplit g m => MonadSplit g (StateT s m) | |
(Monad m, RandomGen g) => MonadSplit g (RandT g m) |