monte-carlo-0.2: A monad and transformer for Monte Carlo calculations.

MaintainerPatrick Perry <>






The Monte Carlo monad

data MC a Source

A Monte Carlo monad with an internal random number generator.

runMC :: MC a -> RNG -> (a, RNG)Source

Run this Monte Carlo monad with the given initial random number generator, getting the result and the new random number generator.

evalMC :: MC a -> RNG -> aSource

Evaluate this Monte Carlo monad and throw away the final random number generator. Very much like fst composed with runMC.

execMC :: MC a -> RNG -> RNGSource

Exicute this Monte Carlo monad and return the final random number generator. Very much like snd composed with runMC.

The Monte Carlo monad transformer

data MCT m a Source

A parameterizable Monte Carlo monad for encapsulating an inner monad.


MonadTrans MCT 
MonadReader r m => MonadReader r (MCT m) 
MonadState s m => MonadState s (MCT m) 
MonadError e m => MonadError e (MCT m) 
MonadWriter w m => MonadWriter w (MCT m) 
Monad m => Monad (MCT m) 
Monad m => Functor (MCT m) 
MonadPlus m => MonadPlus (MCT m) 
MonadCont m => MonadCont (MCT m) 
MonadIO m => MonadIO (MCT m) 
Monad m => MonadMC (MCT m) 
Monad m => HasRNG (MCT m) 

runMCT :: Monad m => MCT m a -> RNG -> m (a, RNG)Source

Similar to runMC.

evalMCT :: Monad m => MCT m a -> RNG -> m aSource

Similar to evalMC.

execMCT :: Monad m => MCT m a -> RNG -> m RNGSource

Similar to execMC.

Pure random number generator creation

data RNG

mt19937 :: Word64 -> RNGSource

Get a Mersenne Twister random number generator seeded with the given value.

Overloaded Monte Carlo monad interface