packages feed

system-random-effect 0.3.0 → 0.3.1

raw patch · 3 files changed

+26/−1 lines, 3 files

Files

src/System/Random/Effect.hs view
@@ -17,6 +17,7 @@                             , runRandomState                             -- * Uniform Distributions                             , uniformIntDist+                            , uniformIntegralDist                             , uniformRealDist                             -- * Bernoulli Distributions                             , bernoulliDist@@ -229,6 +230,23 @@       maxB  = maxBit range    in (a+) <$> uniformIntDist' range maxB {-# INLINE uniformIntDist #-}++-- | Generates a uniformly distributed random number in+--   the inclusive range [a, b].+--+--   This function is more flexible than 'uniformIntDist'+--   since it relaxes type constraints, but passing in+--   constant bounds such as @uniformIntegralDist 0 10@+--   will warn with -Wall.+uniformIntegralDist :: (Member (State Random) r+                     , Integral a)+                    => a -- ^ a+                    -> a -- ^ b+                    -> Eff r a+uniformIntegralDist a b =+  fromInteger <$> uniformIntDist (toInteger a)+                                 (toInteger b)+{-# INLINE uniformIntegralDist #-}  -- | The part of 'uniformRealDist' that does all the work. --   We factor it out so we can inline 'uniformRealDist',
system-random-effect.cabal view
@@ -1,5 +1,5 @@ name:                  system-random-effect-version:               0.3.0+version:               0.3.1 synopsis:              Random number generation for extensible effects. homepage:              https://github.com/wowus/system-random-effect license:               BSD3
test/Test.hs view
@@ -64,9 +64,16 @@           _ <- discreteDist ddh           return True) +testUniformIntegralDist :: Integer -> Integer -> Word64 -> Bool+testUniformIntegralDist a b seed =+  let r1 = runWithSeed seed $ uniformIntDist      a b+      r2 = runWithSeed seed $ uniformIntegralDist a b+   in r1 == r2+ tests =   [ testProperty "random range" testUniformRandom   , testProperty "discrete dist range" testDiscreteDistributionInRange   , testProperty "no non-zero discrete dist pick" testNoZeroDiscreteDistributionPick   , testProperty "unsafeThaw is okay to use" testUnsafeThaw+  , testProperty "testUniformIntegralDist == testUniformIntDist" testUniformIntegralDist   ]