-- 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.1
-- | 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.
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]
-- | 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.
--
--
-- - Computation type: Computations which consume random
-- values.
-- - Binding strategy: The computation proceeds in the same
-- fashion as the identity monad, but it carries a random number
-- generator that may be queried to generate random values.
-- - Useful for: Monte Carlo algorithms and simulating random
-- processes.
--
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, using the random number
-- generator supplied by getStdRandom.
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 (RandomGen g) => RandT g m a
instance Functor (Rand g)
instance Monad (Rand g)
instance (RandomGen g) => MonadRandom (Rand g)
instance (Monad m) => Functor (RandT g m)
instance (Monad m) => Monad (RandT g m)
instance MonadTrans (RandT g)
instance (MonadIO m) => MonadIO (RandT g m)
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 (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) => MonadRandom (RandT g m)