-- 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.6


-- | A type class for random number generation monads. See
--   <a>http://www.haskell.org/haskellwiki/NewMonads/MonadRandom</a> for
--   the original version of this code.
--   
--   Instances of this type class include <a>Rand</a> and monads created
--   using <a>RandT</a>.
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
--   <a>getSplit</a> 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
--   <a>http://www.haskell.org/haskellwiki/NewMonads/MonadRandom</a> for
--   the original version of this code.
--   
--   The actual interface is defined by <a>MonadRandom</a>.
--   
--   <ul>
--   <li><i>Computation type:</i> Computations which consume random
--   values.</li>
--   <li><i>Binding strategy:</i> 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.</li>
--   <li><i>Useful for:</i> Monte Carlo algorithms and simulating random
--   processes.</li>
--   </ul>
module Control.Monad.Random

-- | Evaluate a RandT computation using the generator <tt>g</tt>. Note that
--   the generator <tt>g</tt> is not returned, so there's no way to recover
--   the updated version of <tt>g</tt>.
evalRandT :: (Monad m, RandomGen g) => RandT g m a -> g -> m a

-- | Run a RandT computation using the generator <tt>g</tt>, 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 <tt>g</tt>. Note
--   that the generator <tt>g</tt> is not returned, so there's no way to
--   recover the updated version of <tt>g</tt>.
evalRand :: RandomGen g => Rand g a -> g -> a

-- | Run a random computation using the generator <tt>g</tt>, 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 <a>getStdRandom</a>.
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 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 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 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)
