splitmix-distributions 1.1.0 → 1.2.0
raw patch · 3 files changed
+15/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ System.Random.SplitMix.Distributions: instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (System.Random.SplitMix.Distributions.GenT m)
+ System.Random.SplitMix.Distributions: instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (System.Random.SplitMix.Distributions.GenT m)
+ System.Random.SplitMix.Distributions: uniformInteger :: forall (m :: Type -> Type). Monad m => Integer -> Integer -> GenT m Integer
- System.Random.SplitMix.Distributions: bernoulli :: Monad m => Double -> GenT m Bool
+ System.Random.SplitMix.Distributions: bernoulli :: forall (m :: Type -> Type). Monad m => Double -> GenT m Bool
- System.Random.SplitMix.Distributions: beta :: Monad m => Double -> Double -> GenT m Double
+ System.Random.SplitMix.Distributions: beta :: forall (m :: Type -> Type). Monad m => Double -> Double -> GenT m Double
- System.Random.SplitMix.Distributions: categorical :: (Monad m, Foldable t) => t Double -> GenT m (Maybe Int)
+ System.Random.SplitMix.Distributions: categorical :: forall (m :: Type -> Type) t. (Monad m, Foldable t) => t Double -> GenT m (Maybe Int)
- System.Random.SplitMix.Distributions: crp :: Monad m => Double -> Int -> GenT m [Integer]
+ System.Random.SplitMix.Distributions: crp :: forall (m :: Type -> Type). Monad m => Double -> Int -> GenT m [Integer]
- System.Random.SplitMix.Distributions: data GenT m a
+ System.Random.SplitMix.Distributions: data GenT (m :: Type -> Type) a
- System.Random.SplitMix.Distributions: dirichlet :: (Monad m, Traversable f) => f Double -> GenT m (f Double)
+ System.Random.SplitMix.Distributions: dirichlet :: forall (m :: Type -> Type) f. (Monad m, Traversable f) => f Double -> GenT m (f Double)
- System.Random.SplitMix.Distributions: discrete :: (Monad m, Foldable t) => t (Double, b) -> GenT m (Maybe b)
+ System.Random.SplitMix.Distributions: discrete :: forall (m :: Type -> Type) t b. (Monad m, Foldable t) => t (Double, b) -> GenT m (Maybe b)
- System.Random.SplitMix.Distributions: exponential :: Monad m => Double -> GenT m Double
+ System.Random.SplitMix.Distributions: exponential :: forall (m :: Type -> Type). Monad m => Double -> GenT m Double
- System.Random.SplitMix.Distributions: fairCoin :: Monad m => GenT m Bool
+ System.Random.SplitMix.Distributions: fairCoin :: forall (m :: Type -> Type). Monad m => GenT m Bool
- System.Random.SplitMix.Distributions: gamma :: Monad m => Double -> Double -> GenT m Double
+ System.Random.SplitMix.Distributions: gamma :: forall (m :: Type -> Type). Monad m => Double -> Double -> GenT m Double
- System.Random.SplitMix.Distributions: laplace :: Monad m => Double -> Double -> GenT m Double
+ System.Random.SplitMix.Distributions: laplace :: forall (m :: Type -> Type). Monad m => Double -> Double -> GenT m Double
- System.Random.SplitMix.Distributions: logNormal :: Monad m => Double -> Double -> GenT m Double
+ System.Random.SplitMix.Distributions: logNormal :: forall (m :: Type -> Type). Monad m => Double -> Double -> GenT m Double
- System.Random.SplitMix.Distributions: multinomial :: (Monad m, Foldable t) => Int -> t Double -> GenT m (Maybe [Int])
+ System.Random.SplitMix.Distributions: multinomial :: forall (m :: Type -> Type) t. (Monad m, Foldable t) => Int -> t Double -> GenT m (Maybe [Int])
- System.Random.SplitMix.Distributions: normal :: Monad m => Double -> Double -> GenT m Double
+ System.Random.SplitMix.Distributions: normal :: forall (m :: Type -> Type). Monad m => Double -> Double -> GenT m Double
- System.Random.SplitMix.Distributions: pareto :: Monad m => Double -> Double -> GenT m Double
+ System.Random.SplitMix.Distributions: pareto :: forall (m :: Type -> Type). Monad m => Double -> Double -> GenT m Double
- System.Random.SplitMix.Distributions: stdNormal :: Monad m => GenT m Double
+ System.Random.SplitMix.Distributions: stdNormal :: forall (m :: Type -> Type). Monad m => GenT m Double
- System.Random.SplitMix.Distributions: stdUniform :: Monad m => GenT m Double
+ System.Random.SplitMix.Distributions: stdUniform :: forall (m :: Type -> Type). Monad m => GenT m Double
- System.Random.SplitMix.Distributions: uniformR :: Monad m => Double -> Double -> GenT m Double
+ System.Random.SplitMix.Distributions: uniformR :: forall (m :: Type -> Type). Monad m => Double -> Double -> GenT m Double
- System.Random.SplitMix.Distributions: weibull :: Monad m => Double -> Double -> GenT m Double
+ System.Random.SplitMix.Distributions: weibull :: forall (m :: Type -> Type). Monad m => Double -> Double -> GenT m Double
- System.Random.SplitMix.Distributions: withGen :: Monad m => (SMGen -> (a, SMGen)) -> GenT m a
+ System.Random.SplitMix.Distributions: withGen :: forall (m :: Type -> Type) a. Monad m => (SMGen -> (a, SMGen)) -> GenT m a
- System.Random.SplitMix.Distributions: zipf :: (Monad m, Integral i) => Double -> GenT m i
+ System.Random.SplitMix.Distributions: zipf :: forall (m :: Type -> Type) i. (Monad m, Integral i) => Double -> GenT m i
Files
- ChangeLog.md +5/−0
- splitmix-distributions.cabal +1/−1
- src/System/Random/SplitMix/Distributions.hs +9/−3
ChangeLog.md view
@@ -1,3 +1,8 @@+1.2++- add MonadCatch and MonadFail instances+- add uniformInteger generator+ 1.1 - add sampleRunT and samplesRunT: both return the final state of the PRNG as a tuple of Word64
splitmix-distributions.cabal view
@@ -1,5 +1,5 @@ name: splitmix-distributions-version: 1.1.0+version: 1.2.0 description: Random samplers for some common distributions, as well as a convenient interface for composing them, based on splitmix. Please see the README on GitHub at <https://github.com/ocramz/splitmix-distributions#readme> homepage: https://github.com/ocramz/splitmix-distributions#readme bug-reports: https://github.com/ocramz/splitmix-distributions/issues
src/System/Random/SplitMix/Distributions.hs view
@@ -51,6 +51,7 @@ laplace, weibull, -- ** Discrete+ uniformInteger, bernoulli, fairCoin, multinomial, categorical,@@ -86,13 +87,13 @@ -- erf import Data.Number.Erf (InvErf(..)) -- exceptions-import Control.Monad.Catch (MonadThrow(..))+import Control.Monad.Catch (MonadThrow(..), MonadCatch(..)) -- mtl import Control.Monad.Trans.Class (MonadTrans(..)) import Control.Monad.Reader (MonadReader(..)) import Control.Monad.State (MonadState(..), modify) -- splitmix-import System.Random.SplitMix (SMGen, mkSMGen, seedSMGen', initSMGen, unseedSMGen, splitSMGen, nextDouble)+import System.Random.SplitMix (SMGen, mkSMGen, seedSMGen', initSMGen, unseedSMGen, splitSMGen, nextDouble, nextInteger) -- transformers import Control.Monad.Trans.Reader (ReaderT(..)) import Control.Monad.Trans.State (StateT(..), runStateT, evalStateT, State, runState, evalState)@@ -102,7 +103,8 @@ -- wraps 'splitmix' state-passing inside a 'StateT' monad -- -- useful for embedding random generation inside a larger effect stack-newtype GenT m a = GenT { unGen :: StateT SMGen m a } deriving (Functor, Applicative, Monad, MonadTrans, MonadIO, MonadThrow, MonadReader r)+newtype GenT m a = GenT { unGen :: StateT SMGen m a }+ deriving (Functor, Applicative, Monad, MonadTrans, MonadIO, MonadThrow, MonadCatch, MonadReader r, MonadFail) instance MonadState s m => MonadState s (GenT m) where get = lift get@@ -180,6 +182,10 @@ -> Gen a -> [a] samples n seed gg = sample seed (replicateM n gg)++-- | Uniform integer in the interval [a, b]+uniformInteger :: Monad m => Integer -> Integer -> GenT m Integer+uniformInteger a b = withGen (nextInteger a b) -- | Bernoulli trial bernoulli :: Monad m =>