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


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

-- | Return a randomly-selected value of type <tt>a</tt>. See <a>random</a>
--   for details.
getRandom :: (MonadRandom m, Random a) => m a

-- | Return an infinite stream of random values of type <tt>a</tt>. See
--   <a>randoms</a> for details.
getRandoms :: (MonadRandom m, Random a) => m [a]

-- | Return a randomly-selected value of type <tt>a</tt> in the range
--   <i>[lo,hi]</i>. See <a>randomR</a> for details.
getRandomR :: (MonadRandom m, Random a) => (a, a) -> m a

-- | Return an infinite stream of randomly-selected value of type
--   <tt>a</tt> in the range <i>[lo,hi]</i>. See <a>randomRs</a> for
--   details.
getRandomRs :: (MonadRandom m, Random a) => (a, a) -> m [a]

-- | Return a randomly-selected value of type <tt>a</tt>. See <a>random</a>
--   for details.
getRandom :: (MonadRandom m, Random a) => m a

-- | Return a randomly-selected value of type <tt>a</tt> in the range
--   <i>[lo,hi]</i>. See <a>randomR</a> for details.
getRandomR :: (MonadRandom m, Random a) => (a, a) -> m a

-- | Return an infinite stream of random values of type <tt>a</tt>. See
--   <a>randoms</a> for details.
getRandoms :: (MonadRandom m, Random a) => m [a]

-- | Return an infinite stream of randomly-selected value of type
--   <tt>a</tt> in the range <i>[lo,hi]</i>. See <a>randomRs</a> for
--   details.
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
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) => 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 :: 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 :: Rand g a -> g -> a

-- | Run a random computation using the generator <tt>g</tt>, returning the
--   result and the updated generator.
runRand :: 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

-- | Sample a value from a uniform distribution of a list of elements.
uniform :: (MonadRandom m) => [a] -> m a

-- | A basic random monad.
type Rand g = RandT g Identity

-- | A monad transformer which adds a random number generator to an
--   existing monad.
data RandT g m a

-- | Lift arbitrary action to Rand
liftRand :: (g -> (a, g)) -> Rand g a

-- | Lift arbitrary action to RandT
liftRandT :: (g -> m (a, g)) -> RandT g m a
instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Random.RandT g m)
instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Random.RandT g m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Random.RandT g m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Random.RandT g m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Random.RandT g)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Random.RandT g m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Random.RandT g m)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Random.RandT g m)
instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Random.RandT g m)
instance (GHC.Base.Functor m, GHC.Base.MonadPlus m) => GHC.Base.Alternative (Control.Monad.Random.RandT g m)
instance (GHC.Base.Monad m, System.Random.RandomGen g) => Control.Monad.Random.Class.MonadRandom (Control.Monad.Random.RandT g m)
instance (GHC.Base.Monad m, System.Random.RandomGen g) => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Random.RandT g m)
instance Control.Monad.Random.Class.MonadRandom m => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.Identity.IdentityT m)
instance Control.Monad.Random.Class.MonadRandom m => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.State.Lazy.StateT s m)
instance Control.Monad.Random.Class.MonadRandom m => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.State.Strict.StateT s m)
instance (Control.Monad.Random.Class.MonadRandom m, GHC.Base.Monoid w) => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (Control.Monad.Random.Class.MonadRandom m, GHC.Base.Monoid w) => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance Control.Monad.Random.Class.MonadRandom m => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.Reader.ReaderT r m)
instance (Control.Monad.Random.Class.MonadRandom m, GHC.Base.Monoid w) => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (Control.Monad.Random.Class.MonadRandom m, GHC.Base.Monoid w) => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance Control.Monad.Random.Class.MonadRandom m => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.Except.ExceptT e m)
instance (Control.Monad.Trans.Error.Error e, Control.Monad.Random.Class.MonadRandom m) => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.Error.ErrorT e m)
instance Control.Monad.Random.Class.MonadRandom m => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.Maybe.MaybeT m)
instance Control.Monad.Random.Class.MonadRandom m => Control.Monad.Random.Class.MonadRandom (Control.Monad.Trans.Cont.ContT r m)
instance Control.Monad.Random.Class.MonadSplit g m => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.Identity.IdentityT m)
instance Control.Monad.Random.Class.MonadSplit g m => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.State.Lazy.StateT s m)
instance Control.Monad.Random.Class.MonadSplit g m => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.State.Strict.StateT s m)
instance (Control.Monad.Random.Class.MonadSplit g m, GHC.Base.Monoid w) => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (Control.Monad.Random.Class.MonadSplit g m, GHC.Base.Monoid w) => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance Control.Monad.Random.Class.MonadSplit g m => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.Reader.ReaderT r m)
instance (Control.Monad.Random.Class.MonadSplit g m, GHC.Base.Monoid w) => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (Control.Monad.Random.Class.MonadSplit g m, GHC.Base.Monoid w) => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance Control.Monad.Random.Class.MonadSplit g m => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.Except.ExceptT e m)
instance (Control.Monad.Trans.Error.Error e, Control.Monad.Random.Class.MonadSplit g m) => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.Error.ErrorT e m)
instance Control.Monad.Random.Class.MonadSplit g m => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.Maybe.MaybeT m)
instance Control.Monad.Random.Class.MonadSplit g m => Control.Monad.Random.Class.MonadSplit g (Control.Monad.Trans.Cont.ContT r m)
instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Monad.Random.RandT g m)
instance Control.Monad.Random.Class.MonadRandom GHC.Types.IO
instance Control.Monad.Random.Class.MonadSplit System.Random.StdGen GHC.Types.IO
