packages feed

random-source 0.3.0.6 → 0.3.0.8

raw patch · 5 files changed

+51/−19 lines, 5 filesdep +primitivedep ~basenew-uploader

Dependencies added: primitive

Dependency ranges changed: base

Files

random-source.cabal view
@@ -1,5 +1,5 @@ name:                   random-source-version:                0.3.0.6+version:                0.3.0.8 stability:              provisional  cabal-version:          >= 1.6@@ -85,7 +85,8 @@                         random,                         stateref >= 0.3 && < 0.4,                         template-haskell,-                        th-extras+                        th-extras,+                        primitive    if os(Windows)     cpp-options:        -Dwindows
src/Data/Random/Source/Internal/TH.hs view
@@ -81,17 +81,9 @@     c <- ask     mapReaderT (FD.function (methodNameBase c m)) f -requireMethod :: Method -> ReaderT Context (FD.Defaults s) ()-requireMethod m = do-    c <- ask-    lift (FD.requireFunction (methodNameBase c m))- implementation :: ReaderT Context (FD.Implementation s) (Q [Dec]) -> ReaderT Context (FD.Function s) () implementation = mapReaderT FD.implementation -score :: s -> ReaderT Context (FD.Implementation s) ()-score = lift . FD.score- cost :: Num s => s -> ReaderT Context (FD.Implementation s) () cost = lift . FD.cost @@ -99,15 +91,6 @@ dependsOn m = do     c <- ask     lift (FD.dependsOn (methodNameBase c m))--inline :: ReaderT Context (FD.Implementation s) ()-inline = lift FD.inline--noinline :: ReaderT Context (FD.Implementation s) ()-noinline = lift FD.noinline--replaceMethodName :: (Method -> Name) -> Name -> Name-replaceMethodName f = replace (fmap f . nameToMethod Generic)  changeContext :: Context -> Context -> Name -> Name changeContext c1 c2 = replace (fmap (methodName c2) . nameToMethod c1)
src/Data/Random/Source/MWC.hs view
@@ -19,6 +19,8 @@ import Data.Random.Source import System.Random.MWC import Control.Monad.ST+import Control.Monad.Reader+import Control.Monad.Primitive  $(randomSource     [d| instance RandomSource (ST s) (Gen s) where@@ -37,3 +39,10 @@             getRandomWord64From = uniform             getRandomDoubleFrom = fmap wordToDouble . uniform      |])++$(monadRandom [d|+  instance (PrimMonad m, s ~ PrimState m) => MonadRandom (ReaderT (Gen s) m) where+    getRandomWord16 = ask >>= lift . uniform+    getRandomWord32 = ask >>= lift . uniform+    getRandomWord64 = ask >>= lift . uniform+  |])
src/Data/Random/Source/PureMT.hs view
@@ -25,7 +25,9 @@     ) where  import Control.Monad.State+import Control.Monad.RWS import qualified Control.Monad.State.Strict as S+import qualified Control.Monad.RWS.Strict as S import Data.Random.Internal.Source import Data.Random.Source.Internal.TH import Data.StateRef@@ -58,6 +60,18 @@             getRandomDouble = withMTState randomDouble      |]) +$(monadRandom+    [d| instance Monoid w => MonadRandom (RWS r w PureMT) where+            getRandomWord64 = withMTState randomWord64+            getRandomDouble = withMTState randomDouble+     |])++$(monadRandom+    [d| instance Monoid w => MonadRandom (S.RWS r w PureMT) where+            getRandomWord64 = withMTState randomWord64+            getRandomDouble = withMTState randomDouble+     |])+ #endif  $(randomSource@@ -74,6 +88,18 @@  $(monadRandom     [d| instance Monad m => MonadRandom (S.StateT PureMT m) where+            getRandomWord64 = withMTState randomWord64+            getRandomDouble = withMTState randomDouble+     |])++$(monadRandom+    [d| instance (Monad m, Monoid w) => MonadRandom (RWST r w PureMT m) where+            getRandomWord64 = withMTState randomWord64+            getRandomDouble = withMTState randomDouble+     |])++$(monadRandom+    [d| instance (Monad m, Monoid w) => MonadRandom (S.RWST r w PureMT m) where             getRandomWord64 = withMTState randomWord64             getRandomDouble = withMTState randomDouble      |])
src/Data/Random/Source/StdGen.hs view
@@ -24,8 +24,10 @@ import Data.Random.Internal.Source import System.Random import Control.Monad.State+import Control.Monad.RWS import qualified Control.Monad.ST.Strict as S import qualified Control.Monad.State.Strict as S+import qualified Control.Monad.RWS.Strict as S import Data.StateRef import Data.Word @@ -119,6 +121,12 @@  instance MonadRandom (S.State StdGen) where     getRandomPrim = getRandomPrimFromRandomGenState++instance Monoid w => MonadRandom (RWS r w StdGen) where+    getRandomPrim = getRandomPrimFromRandomGenState++instance Monoid w => MonadRandom (S.RWS r w StdGen) where+    getRandomPrim = getRandomPrimFromRandomGenState #endif  instance Monad m => MonadRandom (StateT StdGen m) where@@ -127,3 +135,8 @@ instance Monad m => MonadRandom (S.StateT StdGen m) where     getRandomPrim = getRandomPrimFromRandomGenState +instance (Monad m, Monoid w) => MonadRandom (RWST r w StdGen m) where+    getRandomPrim = getRandomPrimFromRandomGenState++instance (Monad m, Monoid w) => MonadRandom (S.RWST r w StdGen m) where+    getRandomPrim = getRandomPrimFromRandomGenState