MonadRandom 0.1.11 → 0.1.12
raw patch · 3 files changed
+24/−2 lines, 3 files
Files
- CHANGES.markdown +6/−0
- Control/Monad/Random.hs +16/−1
- MonadRandom.cabal +2/−1
CHANGES.markdown view
@@ -1,3 +1,9 @@+0.1.12 (30 September 2013)+--------------------------++ - add liftRandT and liftRand functions, for lifting explicit+ generator-passing functions into RandT and Rand, respectively.+ 0.1.11 (1 August 2013) ----------------------
Control/Monad/Random.hs view
@@ -36,7 +36,10 @@ runRand, evalRandIO, fromList,- Rand, RandT -- but not the data constructors+ Rand, RandT, -- but not the data constructors+ -- * Special lift functions+ liftRand,+ liftRandT -- * Example -- $RandExample ) where@@ -70,6 +73,18 @@ let (x, v') = t v put v' return x++-- | Lift arbitrary action to RandT+liftRandT :: (Monad m, RandomGen g, Random a) =>+ (g -> m (a, g)) -- ^ action returning value and new generator state+ -> RandT g m a+liftRandT = RandT . StateT++-- | Lift arbitrary action to Rand+liftRand :: (RandomGen g, Random a) =>+ (g -> (a, g)) -- ^ action returning value and new generator state+ -> Rand g a+liftRand = Rand . RandT . liftState instance (Monad m, RandomGen g) => MonadRandom (RandT g m) where getRandom = RandT . liftState $ random
MonadRandom.cabal view
@@ -1,5 +1,5 @@ name: MonadRandom-version: 0.1.11+version: 0.1.12 synopsis: Random-number generation monad. description: Support for computations which consume random values. license: OtherLicense@@ -18,3 +18,4 @@ library exposed-modules: Control.Monad.Random, Control.Monad.Random.Class build-depends: base >= 2 && < 5, transformers, mtl, random+ ghc-options: -Wall