-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Random-number generation monad. -- -- Support for computations which consume random values. @package MonadRandom @version 0.1.8 -- | 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. module Control.Monad.Random.Class -- | An interface to random number generation monads. class Monad m => MonadRandom m getRandom :: (MonadRandom m, Random a) => m a getRandoms :: (MonadRandom m, Random a) => m [a] getRandomR :: (MonadRandom m, Random a) => (a, a) -> m a getRandomRs :: (MonadRandom m, Random a) => (a, a) -> m [a] -- | 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. class Monad m => MonadSplit s m | m -> s getSplit :: MonadSplit s m => m s -- | A random number generation monad. See -- http://www.haskell.org/haskellwiki/NewMonads/MonadRandom for -- the original version of this code. -- -- The actual interface is defined by MonadRandom. -- -- module Control.Monad.Random -- | Evaluate a RandT computation using the generator g. Note that -- the generator g is not returned, so there's no way to recover -- the updated version of g. evalRandT :: (Monad m, RandomGen g) => RandT g m a -> g -> m a -- | Run a RandT computation using the generator g, returning the -- result and the updated generator. runRandT :: (Monad m, RandomGen g) => RandT g m a -> g -> m (a, g) -- | Evaluate a random computation using the generator g. Note -- that the generator g is not returned, so there's no way to -- recover the updated version of g. evalRand :: RandomGen g => Rand g a -> g -> a -- | Run a random computation using the generator g, returning the -- result and the updated generator. runRand :: RandomGen g => Rand g a -> g -> (a, g) -- | Evaluate a random computation in the IO monad, splitting the global -- standard generator to get a new one for the computation. evalRandIO :: Rand StdGen a -> IO a -- | Sample a random value from a weighted list. The total weight of all -- elements must not be 0. fromList :: MonadRandom m => [(a, Rational)] -> m a -- | A basic random monad. data Rand g a -- | A monad transformer which adds a random number generator to an -- existing monad. data RandT g m a instance Functor m => Functor (RandT g m) instance Monad m => Monad (RandT g m) instance MonadTrans (RandT g) instance MonadIO m => MonadIO (RandT g m) instance MonadFix m => MonadFix (RandT g m) instance Functor (Rand g) instance Applicative (Rand g) instance Monad (Rand g) instance RandomGen g => MonadRandom (Rand g) instance RandomGen g => MonadSplit g (Rand g) instance MonadFix (Rand g) instance MonadSplit StdGen IO instance MonadRandom IO instance (MonadWriter w m, RandomGen g, Monoid w) => MonadWriter w (RandT g m) instance (MonadReader r m, RandomGen g) => MonadReader r (RandT g m) instance (MonadState s m, RandomGen g) => MonadState s (RandT g m) instance (Error e, MonadSplit g m) => MonadSplit g (ErrorT e m) instance MonadSplit g m => MonadSplit g (ReaderT r m) instance (MonadSplit g m, Monoid w) => MonadSplit g (WriterT w m) instance MonadSplit g m => MonadSplit g (StateT s m) instance (Error e, MonadRandom m) => MonadRandom (ErrorT e m) instance MonadRandom m => MonadRandom (ReaderT r m) instance (MonadRandom m, Monoid w) => MonadRandom (WriterT w m) instance MonadRandom m => MonadRandom (StateT s m) instance (Monad m, RandomGen g) => MonadSplit g (RandT g m) instance (Monad m, RandomGen g) => MonadRandom (RandT g m) instance (Functor m, Monad m) => Applicative (RandT g m)