splitmix-distributions 0.9.0.0 → 1.0.0
raw patch · 4 files changed
+20/−4 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- System.Random.SplitMix.Distributions: instance GHC.Base.Monad m => Control.Monad.State.Class.MonadState System.Random.SplitMix.SMGen (System.Random.SplitMix.Distributions.GenT m)
+ System.Random.SplitMix.Distributions: instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (System.Random.SplitMix.Distributions.GenT m)
+ System.Random.SplitMix.Distributions: instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (System.Random.SplitMix.Distributions.GenT m)
Files
- ChangeLog.md +5/−0
- LICENSE +2/−2
- splitmix-distributions.cabal +1/−1
- src/System/Random/SplitMix/Distributions.hs +12/−1
ChangeLog.md view
@@ -1,3 +1,8 @@+1.0++- add MonadReader r (GenT m) instance+- fixed MonadState (GenT m) instance via MonadTrans (i.e. as done in 'mtl')+ 0.9 : - ensure it builds with ghc 8.6.5 (== stackage lts 14.27) as well
LICENSE view
@@ -1,4 +1,4 @@-Copyright Author name here (c) 2021+Copyright Marco Zocca (c) 2021 All rights reserved. @@ -13,7 +13,7 @@ disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Author name here nor the names of other+ * Neither the name of Marco Zocca nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
splitmix-distributions.cabal view
@@ -1,5 +1,5 @@ name: splitmix-distributions-version: 0.9.0.0+version: 1.0.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
@@ -1,4 +1,7 @@+{-# LANGUAGE FlexibleInstances #-} {-# language GeneralizedNewtypeDeriving #-}+{-# language MultiParamTypeClasses #-}+{-# language UndecidableInstances #-} {-# options_ghc -Wno-unused-imports #-} {-| Random samplers for few common distributions, with an interface similar to that of @mwc-probability@.@@ -81,10 +84,12 @@ import Control.Monad.Catch (MonadThrow(..)) -- 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, initSMGen, unseedSMGen, splitSMGen, nextDouble) -- transformers+import Control.Monad.Trans.Reader (ReaderT(..)) import Control.Monad.Trans.State (StateT(..), runStateT, evalStateT, State, runState, evalState) -- | Random generator@@ -92,7 +97,13 @@ -- 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, MonadState SMGen, MonadTrans, MonadIO, MonadThrow)+newtype GenT m a = GenT { unGen :: StateT SMGen m a } deriving (Functor, Applicative, Monad, MonadTrans, MonadIO, MonadThrow, MonadReader r)++instance MonadState s m => MonadState s (GenT m) where+ get = lift get+ put = lift . put+ state = lift . state+ -- | Pure random generation type Gen = GenT Identity