MonadRandom 0.5.3 → 0.6.2.1
raw patch · 5 files changed
Files
- CHANGES.markdown +42/−1
- Control/Monad/Random/Class.hs +152/−164
- Control/Monad/Trans/Random/Lazy.hs +20/−15
- Control/Monad/Trans/Random/Strict.hs +17/−13
- MonadRandom.cabal +9/−12
CHANGES.markdown view
@@ -1,9 +1,50 @@+0.6.2.1 (19 January 2026)+-------------------------++- Test with GHC 9.14+- Drop support for GHC < 8+- Drop `transformers-compat` dependency++0.6.2 (5 March 2025)+--------------------++- Support `random-1.3`. Thanks to @bgamari and @lehins for help+ making the necessary updates.++0.6.1 (22 October 2024)+-----------------------++- Fix the potential for a crash in `fromListMay` (and hence also in+ functions that use it, namely `fromList`, `weighted`, `weightedMay`,+ `uniform`, and `uniformMay`). Thanks to @Flupp for pointing out the+ issue and suggesting a fix. The fix may in theory cause these+ functions, extremely rarely, to output values different from the old+ values for the same seed. See+ https://byorgey.github.io/blog/posts/2024/10/14/MonadRandom-version-bump.html+ for more information and discussion.++0.6 (5 Nov 2022)+----------------++- Remove instances for deprecated `ErrorT` and `ListT` transformers+- Allow building with `transformers-0.6` and `mtl-2.3.1`+- Drop support for GHC 7.6 and 7.8++- r1 (18 Dec 2022): require `base >= 4.8`+- r2 (9 Jan 2023): require `random >= 1.0.1`+- r3 (22 Feb 2023): allow `primitive-0.8`+- r4 (12 Oct 2023): allow `primitive-0.9`, test on GHC 9.6 and 9.8+ 0.5.3 (8 April 2021) -------------------- - `StatefulGen` instances for `RandT` - Addition of `RandGen`-- Additioon of `withRandGen` and `withRandGen_`+- Addition of `withRandGen` and `withRandGen_`++- r1 (28 April 2021): require `base >= 4.6`+- r2 (9 Aug 2021): allow `transformers-compat-0.7`.+- r3 (9 Aug 2022): Test with GHC 9.0-9.4 0.5.2 (24 June 2020) --------------------
Control/Monad/Random/Class.hs view
@@ -1,74 +1,68 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE Safe #-}-{-# LANGUAGE UndecidableInstances #-}--{- |-Module : Control.Monad.Random.Class-Copyright : (c) Brent Yorgey 2016-License : BSD3 (see LICENSE)-Maintainer : byorgey@gmail.com--The 'MonadRandom', 'MonadSplit', and 'MonadInterleave' classes.--* 'MonadRandom' abstracts over monads with the capability of- generating random values.--* 'MonadSplit' abstracts over random monads with the ability to get a- split generator state. It is not very useful but kept here for- backwards compatibility.--* 'MonadInterleave' abstracts over random monads supporting an- 'interleave' operation, which allows sequencing computations which do- not depend on each other's random generator state, by splitting the- generator between them.--This module also defines convenience functions for sampling from a-given collection of values, either uniformly or according to given-weights.---}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE Safe #-}+{-# LANGUAGE UndecidableInstances #-} +-- |+-- Module : Control.Monad.Random.Class+-- Copyright : (c) Brent Yorgey 2016+-- License : BSD3 (see LICENSE)+-- Maintainer : byorgey@gmail.com+--+-- The 'MonadRandom', 'MonadSplit', and 'MonadInterleave' classes.+--+-- * 'MonadRandom' abstracts over monads with the capability of+-- generating random values.+--+-- * 'MonadSplit' abstracts over random monads with the ability to get a+-- split generator state. It is not very useful but kept here for+-- backwards compatibility.+--+-- * 'MonadInterleave' abstracts over random monads supporting an+-- 'interleave' operation, which allows sequencing computations which do+-- not depend on each other's random generator state, by splitting the+-- generator between them.+--+-- This module also defines convenience functions for sampling from a+-- given collection of values, either uniformly or according to given+-- weights. module Control.Monad.Random.Class (-- -- * MonadRandom- MonadRandom(..),+ -- * MonadRandom+ MonadRandom (..), - -- * MonadSplit- MonadSplit(..),+ -- * MonadSplit+ MonadSplit (..), - -- * MonadInterleave- MonadInterleave(..),+ -- * MonadInterleave+ MonadInterleave (..), - -- * Sampling functions- fromList,- fromListMay,- uniform,- uniformMay,- weighted,- weightedMay- ) where+ -- * Sampling functions+ fromList,+ fromListMay,+ uniform,+ uniformMay,+ weighted,+ weightedMay,+) where -import Control.Monad-import Control.Monad.Trans.Class-import Control.Monad.Trans.Cont-import Control.Monad.Trans.Error-import Control.Monad.Trans.Except-import Control.Monad.Trans.Identity-import Control.Monad.Trans.List-import Control.Monad.Trans.Maybe-import Control.Monad.Trans.Reader-import qualified Control.Monad.Trans.RWS.Lazy as LazyRWS-import qualified Control.Monad.Trans.RWS.Strict as StrictRWS-import qualified Control.Monad.Trans.State.Lazy as LazyState-import qualified Control.Monad.Trans.State.Strict as StrictState-import qualified Control.Monad.Trans.Writer.Lazy as LazyWriter+import Control.Monad+import Control.Monad.Trans.Class+import Control.Monad.Trans.Cont+import Control.Monad.Trans.Except+import Control.Monad.Trans.Identity+import Control.Monad.Trans.Maybe+import qualified Control.Monad.Trans.RWS.Lazy as LazyRWS+import qualified Control.Monad.Trans.RWS.Strict as StrictRWS+import Control.Monad.Trans.Reader+import qualified Control.Monad.Trans.State.Lazy as LazyState+import qualified Control.Monad.Trans.State.Strict as StrictState+import qualified Control.Monad.Trans.Writer.Lazy as LazyWriter import qualified Control.Monad.Trans.Writer.Strict as StrictWriter-import qualified System.Random as Random--import qualified Data.Foldable as F+import qualified Data.Foldable as F+import Data.Word (Word64)+import qualified System.Random as Random #if MIN_VERSION_base(4,8,0) #else@@ -81,7 +75,7 @@ -- | With a source of random number supply in hand, the 'MonadRandom' class -- allows the programmer to extract random values of a variety of types.-class (Monad m) => MonadRandom m where+class Monad m => MonadRandom m where -- | Takes a range /(lo,hi)/ and a random number generator -- /g/, and returns a computation that returns a random value uniformly -- distributed in the closed interval /[lo,hi]/, together with a new@@ -91,7 +85,7 @@ -- interval. -- -- See 'System.Random.randomR' for details.- getRandomR :: (Random.Random a) => (a, a) -> m a+ getRandomR :: Random.Random a => (a, a) -> m a -- | The same as 'getRandomR', but using a default range determined by the type: --@@ -104,103 +98,91 @@ -- * For 'Integer', the range is (arbitrarily) the range of 'Int'. -- -- See 'System.Random.random' for details.- getRandom :: (Random.Random a) => m a+ getRandom :: Random.Random a => m a -- | Plural variant of 'getRandomR', producing an infinite list of -- random values instead of returning a new generator. -- -- See 'System.Random.randomRs' for details.- getRandomRs :: (Random.Random a) => (a, a) -> m [a]+ getRandomRs :: Random.Random a => (a, a) -> m [a] -- | Plural variant of 'getRandom', producing an infinite list of -- random values instead of returning a new generator. -- -- See 'System.Random.randoms' for details.- getRandoms :: (Random.Random a) => m [a]+ getRandoms :: Random.Random a => m [a] instance MonadRandom IO where- getRandomR = Random.randomRIO- getRandom = Random.randomIO+ getRandomR = Random.randomRIO+ getRandom = Random.randomIO getRandomRs lohi = liftM (Random.randomRs lohi) Random.newStdGen- getRandoms = liftM Random.randoms Random.newStdGen--instance (MonadRandom m) => MonadRandom (ContT r m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom- getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms--instance (Error e, MonadRandom m) => MonadRandom (ErrorT e m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom- getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = liftM Random.randoms Random.newStdGen -instance (MonadRandom m) => MonadRandom (ExceptT e m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+instance MonadRandom m => MonadRandom (ContT r m) where+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms -instance (MonadRandom m) => MonadRandom (IdentityT m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+instance MonadRandom m => MonadRandom (ExceptT e m) where+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms -instance (MonadRandom m) => MonadRandom (ListT m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+instance MonadRandom m => MonadRandom (IdentityT m) where+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms -instance (MonadRandom m) => MonadRandom (MaybeT m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+instance MonadRandom m => MonadRandom (MaybeT m) where+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms instance (Monoid w, MonadRandom m) => MonadRandom (LazyRWS.RWST r w s m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms instance (Monoid w, MonadRandom m) => MonadRandom (StrictRWS.RWST r w s m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms -instance (MonadRandom m) => MonadRandom (ReaderT r m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+instance MonadRandom m => MonadRandom (ReaderT r m) where+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms -instance (MonadRandom m) => MonadRandom (LazyState.StateT s m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+instance MonadRandom m => MonadRandom (LazyState.StateT s m) where+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms -instance (MonadRandom m) => MonadRandom (StrictState.StateT s m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+instance MonadRandom m => MonadRandom (StrictState.StateT s m) where+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms instance (MonadRandom m, Monoid w) => MonadRandom (LazyWriter.WriterT w m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms instance (MonadRandom m, Monoid w) => MonadRandom (StrictWriter.WriterT w m) where- getRandomR = lift . getRandomR- getRandom = lift getRandom+ getRandomR = lift . getRandomR+ getRandom = lift getRandom getRandomRs = lift . getRandomRs- getRandoms = lift getRandoms+ getRandoms = lift getRandoms ------------------------------------------------------------ -- MonadSplit@@ -213,8 +195,7 @@ -- actually do anything with a generator. It remains here to avoid -- breaking existing code unnecessarily. For a more practically -- useful interface, see 'MonadInterleave'.-class (Monad m) => MonadSplit g m | m -> g where-+class Monad m => MonadSplit g m | m -> g where -- | The 'getSplit' operation allows one to obtain two distinct random number -- generators. --@@ -224,22 +205,16 @@ instance MonadSplit Random.StdGen IO where getSplit = Random.newStdGen -instance (MonadSplit g m) => MonadSplit g (ContT r m) where- getSplit = lift getSplit--instance (Error e, MonadSplit g m) => MonadSplit g (ErrorT e m) where- getSplit = lift getSplit--instance (MonadSplit g m) => MonadSplit g (ExceptT e m) where+instance MonadSplit g m => MonadSplit g (ContT r m) where getSplit = lift getSplit -instance (MonadSplit g m) => MonadSplit g (IdentityT m) where+instance MonadSplit g m => MonadSplit g (ExceptT e m) where getSplit = lift getSplit -instance (MonadSplit g m) => MonadSplit g (ListT m) where+instance MonadSplit g m => MonadSplit g (IdentityT m) where getSplit = lift getSplit -instance (MonadSplit g m) => MonadSplit g (MaybeT m) where+instance MonadSplit g m => MonadSplit g (MaybeT m) where getSplit = lift getSplit instance (Monoid w, MonadSplit g m) => MonadSplit g (LazyRWS.RWST r w s m) where@@ -248,13 +223,13 @@ instance (Monoid w, MonadSplit g m) => MonadSplit g (StrictRWS.RWST r w s m) where getSplit = lift getSplit -instance (MonadSplit g m) => MonadSplit g (ReaderT r m) where+instance MonadSplit g m => MonadSplit g (ReaderT r m) where getSplit = lift getSplit -instance (MonadSplit g m) => MonadSplit g (LazyState.StateT s m) where+instance MonadSplit g m => MonadSplit g (LazyState.StateT s m) where getSplit = lift getSplit -instance (MonadSplit g m) => MonadSplit g (StrictState.StateT s m) where+instance MonadSplit g m => MonadSplit g (StrictState.StateT s m) where getSplit = lift getSplit instance (Monoid w, MonadSplit g m) => MonadSplit g (LazyWriter.WriterT w m) where@@ -270,7 +245,6 @@ -- | The class 'MonadInterleave' proivides a convenient interface atop -- a 'split' operation on a random generator. class MonadRandom m => MonadInterleave m where- -- | If @x :: m a@ is a computation in some random monad, then -- @interleave x@ works by splitting the generator, running @x@ -- using one half, and using the other half as the final generator@@ -315,22 +289,16 @@ -- > Node 8243316398511136358 (Node 4139784028141790719 Leaf Leaf) (Node 4473998613878251948 Leaf Leaf) interleave :: m a -> m a -instance (MonadInterleave m) => MonadInterleave (ContT r m) where+instance MonadInterleave m => MonadInterleave (ContT r m) where interleave = mapContT interleave -instance (Error e, MonadInterleave m) => MonadInterleave (ErrorT e m) where- interleave = mapErrorT interleave--instance (MonadInterleave m) => MonadInterleave (ExceptT e m) where+instance MonadInterleave m => MonadInterleave (ExceptT e m) where interleave = mapExceptT interleave -instance (MonadInterleave m) => MonadInterleave (IdentityT m) where+instance MonadInterleave m => MonadInterleave (IdentityT m) where interleave = mapIdentityT interleave -instance (MonadInterleave m) => MonadInterleave (ListT m) where- interleave = mapListT interleave--instance (MonadInterleave m) => MonadInterleave (MaybeT m) where+instance MonadInterleave m => MonadInterleave (MaybeT m) where interleave = mapMaybeT interleave instance (Monoid w, MonadInterleave m) => MonadInterleave (LazyRWS.RWST r w s m) where@@ -339,13 +307,13 @@ instance (Monoid w, MonadInterleave m) => MonadInterleave (StrictRWS.RWST r w s m) where interleave = StrictRWS.mapRWST interleave -instance (MonadInterleave m) => MonadInterleave (ReaderT r m) where+instance MonadInterleave m => MonadInterleave (ReaderT r m) where interleave = mapReaderT interleave -instance (MonadInterleave m) => MonadInterleave (LazyState.StateT s m) where+instance MonadInterleave m => MonadInterleave (LazyState.StateT s m) where interleave = LazyState.mapStateT interleave -instance (MonadInterleave m) => MonadInterleave (StrictState.StateT s m) where+instance MonadInterleave m => MonadInterleave (StrictState.StateT s m) where interleave = StrictState.mapStateT interleave instance (Monoid w, MonadInterleave m) => MonadInterleave (LazyWriter.WriterT w m) where@@ -366,7 +334,7 @@ ma <- weightedMay t case ma of Nothing -> error "Control.Monad.Random.Class.weighted: empty collection, or total weight <= 0"- Just a -> return a+ Just a -> return a -- | Sample a random value from a weighted collection of elements. -- Returns @Nothing@ if the collection is empty or the total weight is@@ -376,24 +344,29 @@ -- | Sample a random value from a weighted list. The list must be -- non-empty and the total weight must be non-zero.-fromList :: (MonadRandom m) => [(a, Rational)] -> m a+fromList :: MonadRandom m => [(a, Rational)] -> m a fromList ws = do ma <- fromListMay ws case ma of Nothing -> error "Control.Monad.Random.Class.fromList: empty list, or total weight = 0"- Just a -> return a+ Just a -> return a -- | Sample a random value from a weighted list. Return @Nothing@ if -- the list is empty or the total weight is nonpositive.-fromListMay :: (MonadRandom m) => [(a, Rational)] -> m (Maybe a)+fromListMay :: MonadRandom m => [(a, Rational)] -> m (Maybe a) fromListMay xs = do- let s = fromRational (sum (map snd xs)) :: Double- cums = scanl1 (\ ~(_,q) ~(y,s') -> (y, s'+q)) xs- case s <= 0 of- True -> return Nothing- _ -> do- p <- liftM toRational $ getRandomR (0, s)- return . Just . fst . head . dropWhile ((< p) . snd) $ cums+ let s = sum (map snd xs)+ cums = scanl1 (\ ~(_, q) ~(y, s') -> (y, s' + q)) xs+ if s <= 0+ then return Nothing+ else do+ -- Pick a Word64 value uniformly+ w <- getRandom+ -- w / maxBound gives a uniform Rational in the range [0,1].+ -- Subtract from 1 to match the way uniform Double values are+ -- generated, and hence match the old behavior of this function.+ let p = s * (1 - toRational (w :: Word64) / toRational (maxBound :: Word64))+ return . fmap fst . F.find ((>= p) . snd) $ cums -- | Sample a value uniformly from a nonempty collection of elements. uniform :: (F.Foldable t, MonadRandom m) => t a -> m a@@ -401,9 +374,24 @@ ma <- uniformMay t case ma of Nothing -> error "Control.Monad.Random.Class.uniform: empty collection"- Just a -> return a+ Just a -> return a -- | Sample a value uniformly from a collection of elements. Return -- @Nothing@ if the collection is empty. uniformMay :: (F.Foldable t, MonadRandom m) => t a -> m (Maybe a) uniformMay = fromListMay . map (flip (,) 1) . F.toList++------------------------------------------------------------++-- The old implementation of `fromListMay`, for comparison. See+-- https://github.com/byorgey/MonadRandom/issues/53 and+-- https://byorgey.github.io/blog/posts/2024/10/14/MonadRandom-version-bump.html+_fromListMayOld :: MonadRandom m => [(a, Rational)] -> m (Maybe a)+_fromListMayOld xs = do+ let s = fromRational (sum (map snd xs)) :: Double+ cums = scanl1 (\ ~(_, q) ~(y, s') -> (y, s' + q)) xs+ if s <= 0+ then return Nothing+ else do+ p <- liftM toRational $ getRandomR (0, s)+ return . fmap fst . F.find ((>= p) . snd) $ cums
Control/Monad/Trans/Random/Lazy.hs view
@@ -56,27 +56,28 @@ -- $examples ) where -import Control.Applicative-import Control.Arrow (first)-import Control.Monad-import Control.Monad.Cont.Class-import Control.Monad.Error.Class-import qualified Control.Monad.Fail as Fail-import Control.Monad.Fix-import Control.Monad.IO.Class-import Control.Monad.Primitive-import Control.Monad.Random.Class-import Control.Monad.RWS.Class-import Control.Monad.Signatures-import Control.Monad.Trans.Class+import Control.Applicative ( Alternative )+import Control.Arrow (first)+import Control.Monad ( liftM, MonadPlus )+import Control.Monad.Cont.Class (MonadCont(..))+import Control.Monad.Error.Class ( MonadError(..) )+import qualified Control.Monad.Fail as Fail+import Control.Monad.Fix ( MonadFix )+import Control.Monad.IO.Class ( MonadIO(..) )+import Control.Monad.Primitive ( PrimMonad(..) )+import Control.Monad.Random.Class ( MonadInterleave(..), MonadSplit(..), MonadRandom(..) )+import Control.Monad.RWS.Class ( MonadState(..), MonadRWS, MonadReader, MonadWriter )+import Control.Monad.Signatures ( Listen, Pass, CallCC, Catch )+import Control.Monad.Trans.Class ( MonadTrans(..) ) import qualified Control.Monad.Trans.State.Lazy as LazyState-import Control.Monad.Trans.Random.Strict (RandGen(..))-import Data.Functor.Identity+import Control.Monad.Trans.Random.Strict (RandGen(..))+import Data.Functor.Identity ( Identity(runIdentity) ) #if MIN_VERSION_random(1,2,0) import System.Random.Stateful #else import System.Random #endif+ -- | A random monad parameterized by the type @g@ of the generator to carry. -- -- The 'return' function leaves the generator unchanged, while '>>=' uses the@@ -281,7 +282,11 @@ uniformWord16 = applyRandT genWord16 uniformWord32 = applyRandT genWord32 uniformWord64 = applyRandT genWord64+#if MIN_VERSION_random(1,3,0)+ uniformByteArrayM pinned sz = applyRandT $ uniformByteArray pinned sz+#else uniformShortByteString n = applyRandT (genShortByteString n)+#endif -- | --
Control/Monad/Trans/Random/Strict.hs view
@@ -57,21 +57,21 @@ -- $examples ) where -import Control.Applicative-import Control.Arrow (first)-import Control.Monad-import Control.Monad.Cont.Class-import Control.Monad.Error.Class+import Control.Applicative ( Alternative )+import Control.Arrow (first)+import Control.Monad ( liftM, MonadPlus )+import Control.Monad.Cont.Class (MonadCont(..))+import Control.Monad.Error.Class ( MonadError(..) ) import qualified Control.Monad.Fail as Fail-import Control.Monad.Fix-import Control.Monad.IO.Class-import Control.Monad.Primitive-import Control.Monad.Random.Class-import Control.Monad.RWS.Class-import Control.Monad.Signatures-import Control.Monad.Trans.Class+import Control.Monad.Fix ( MonadFix )+import Control.Monad.IO.Class ( MonadIO(..) )+import Control.Monad.Primitive ( PrimMonad(..) )+import Control.Monad.Random.Class ( MonadInterleave(..), MonadSplit(..), MonadRandom(..) )+import Control.Monad.RWS.Class ( MonadState(..), MonadRWS, MonadReader, MonadWriter )+import Control.Monad.Signatures ( Listen, Pass, CallCC, Catch )+import Control.Monad.Trans.Class ( MonadTrans(..) ) import qualified Control.Monad.Trans.State.Strict as StrictState-import Data.Functor.Identity+import Data.Functor.Identity ( Identity(runIdentity) ) #if MIN_VERSION_random(1,2,0) import System.Random.Stateful #else@@ -289,7 +289,11 @@ uniformWord16 = applyRandT genWord16 uniformWord32 = applyRandT genWord32 uniformWord64 = applyRandT genWord64+#if MIN_VERSION_random(1,3,0)+ uniformByteArrayM pinned sz = applyRandT $ uniformByteArray pinned sz+#else uniformShortByteString n = applyRandT (genShortByteString n)+#endif -- | --
MonadRandom.cabal view
@@ -1,5 +1,5 @@ name: MonadRandom-version: 0.5.3+version: 0.6.2.1 synopsis: Random-number generation monad. description: Support for computations which consume random values. license: BSD3@@ -11,11 +11,11 @@ build-type: Simple cabal-version: >=1.10 extra-source-files: CHANGES.markdown-tested-with: GHC ==7.6.3 || ==7.8.4 || ==7.10.3 || ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.3 || ==8.10.1+tested-with: GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2 || ==9.10.1 || ==9.12.1 || ==9.14.1 source-repository head type: git- location: git://github.com/byorgey/MonadRandom.git+ location: https://github.com/byorgey/MonadRandom library exposed-modules:@@ -27,14 +27,11 @@ Control.Monad.Trans.Random.Lazy, Control.Monad.Trans.Random.Strict build-depends:- base >=2 && <5,- transformers >=0.3 && <0.6,- transformers-compat >=0.4 && <0.7,- mtl >=2.1 && <2.3,- primitive >=0.6 && <0.8,- random >=1.0 && <1.3+ base >=4.8 && <5,+ transformers >=0.5 && <0.7,+ mtl >=2.2.1 && <2.3 || >= 2.3.1 && < 2.4,+ primitive >=0.6 && <0.10,+ random >=1.0.1 && <1.4 ghc-options: -Wall default-language: Haskell2010-- if impl(ghc < 8.0)- build-depends: fail >= 4.9+ other-extensions: Safe