pcg-random 0.1.3.0 → 0.1.3.1
raw patch · 6 files changed
+36/−14 lines, 6 files
Files
- CHANGELOG.md +4/−0
- pcg-random.cabal +1/−1
- src/System/Random/PCG.hs +10/−4
- src/System/Random/PCG/Class.hs +1/−1
- src/System/Random/PCG/Fast.hs +10/−4
- src/System/Random/PCG/Single.hs +10/−4
CHANGELOG.md view
@@ -1,3 +1,7 @@+### 0.1.3.1++* Added `withFrozen` function.+ ### 0.1.3.0 * Use [entropy](http://hackage.haskell.org/package/entropy) package for
pcg-random.cabal view
@@ -1,5 +1,5 @@ name: pcg-random-version: 0.1.3.0+version: 0.1.3.1 synopsis: Haskell bindings to the PCG random number generator. description: PCG is a family of simple fast space-efficient statistically good
src/System/Random/PCG.hs view
@@ -3,8 +3,9 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ForeignFunctionInterface #-}-{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE TypeFamilies #-} #if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE RoleAnnotations #-} #endif@@ -36,7 +37,8 @@ module System.Random.PCG ( -- * Generator Gen, GenIO, GenST- , create, createSystemRandom, initialize, withSystemRandom+ , create, createSystemRandom, initialize+ , withSystemRandom, withFrozen -- * Getting random numbers , Variate (..)@@ -63,10 +65,9 @@ , uniformBF, uniformBD, uniformBBool ) where -#if __GLASGOW_HASKELL__ < 710 import Control.Applicative-#endif import Control.Monad.Primitive+import Control.Monad.ST import Data.Data import Foreign import GHC.Generics@@ -172,6 +173,11 @@ w1 <- sysRandom w2 <- sysRandom initialize w1 w2 >>= f++-- | Run an action with a frozen generator, returning the result and the+-- new frozen generator.+withFrozen :: FrozenGen -> (forall s. Gen s -> ST s a) -> (a, FrozenGen)+withFrozen s f = runST $ restore s >>= \g -> liftA2 (,) (f g) (save g) -- | Seed a PRNG with data from the system's fast source of pseudo-random -- numbers. All the caveats of 'withSystemRandom' apply here as well.
src/System/Random/PCG/Class.hs view
@@ -416,7 +416,7 @@ -- IO randoms --- | Generate a random number using 'System.Entropy'.+-- | Generate a random number using "System.Entropy". -- -- Use RDRAND if available and XOR with @\/dev\/urandom@ on Unix and -- CryptAPI on Windows. This entropy is considered cryptographically
src/System/Random/PCG/Fast.hs view
@@ -3,9 +3,10 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ForeignFunctionInterface #-}-{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE TypeFamilies #-} #if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE RoleAnnotations #-} #endif@@ -38,7 +39,8 @@ module System.Random.PCG.Fast ( -- * Gen Gen, GenIO, GenST- , create, createSystemRandom, initialize, withSystemRandom+ , create, createSystemRandom, initialize+ , withSystemRandom, withFrozen -- * Getting random numbers , Variate (..)@@ -64,10 +66,9 @@ , uniformBF, uniformBD, uniformBBool ) where -#if __GLASGOW_HASKELL__ < 710 import Control.Applicative-#endif import Control.Monad.Primitive+import Control.Monad.ST import Data.Data import Foreign import GHC.Generics@@ -152,6 +153,11 @@ withSystemRandom f = do w <- sysRandom initialize w >>= f++-- | Run an action with a frozen generator, returning the result and the+-- new frozen generator.+withFrozen :: FrozenGen -> (forall s. Gen s -> ST s a) -> (a, FrozenGen)+withFrozen s f = runST $ restore s >>= \g -> liftA2 (,) (f g) (save g) -- | Seed a PRNG with data from the system's fast source of pseudo-random -- numbers. All the caveats of 'withSystemRandom' apply here as well.
src/System/Random/PCG/Single.hs view
@@ -3,9 +3,10 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ForeignFunctionInterface #-}-{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE TypeFamilies #-} #if __GLASGOW_HASKELL__ >= 707 {-# LANGUAGE RoleAnnotations #-} #endif@@ -36,7 +37,8 @@ module System.Random.PCG.Single ( -- * Gen Gen, GenIO, GenST- , create, createSystemRandom, initialize, withSystemRandom+ , create, createSystemRandom, initialize+ , withSystemRandom, withFrozen -- * Getting random numbers , Variate (..)@@ -63,10 +65,9 @@ , uniformBF, uniformBD, uniformBBool ) where -#if __GLASGOW_HASKELL__ < 710 import Control.Applicative-#endif import Control.Monad.Primitive+import Control.Monad.ST import Data.Data import Foreign import GHC.Generics@@ -145,6 +146,11 @@ -- systems, time otherwise). withSystemRandom :: (GenIO -> IO a) -> IO a withSystemRandom f = sysRandom >>= initialize >>= f++-- | Run an action with a frozen generator, returning the result and the+-- new frozen generator.+withFrozen :: FrozenGen -> (forall s. Gen s -> ST s a) -> (a, FrozenGen)+withFrozen s f = runST $ restore s >>= \g -> liftA2 (,) (f g) (save g) -- | Seed a PRNG with data from the system's fast source of pseudo-random -- numbers. All the caveats of 'withSystemRandom' apply here as well.