h$cl^4      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(c) Andrew Lelechenko 2020;BSD-style (see the file LICENSE in the 'random' repository)libraries@haskell.orgNone9?randomA type class for data with a finite number of inhabitants. This type class is used in default implementations of .-Users are not supposed to write instances of : manually. There is a default implementation in terms of  instead.%:set -XDeriveGeneric -XDeriveAnyClassimport GHC.Generics (Generic)9data MyBool = MyTrue | MyFalse deriving (Generic, Finite)data Action = Code MyBool | Eat (Maybe Bool) | Sleep deriving (Generic, Finite)randomCardinality of a set.random%Shift n is equivalent to Card (bit n)random'This is needed only as a superclass of .random'This is needed only as a superclass of . "(c) The University of Glasgow 2001;BSD-style (see the file LICENSE in the 'random' repository)libraries@haskell.orgstable Trustworthy 9>?-?5randomThe class of types for which a uniformly distributed value can be drawn from a range.randomGenerates a value uniformly distributed over the provided range, which is interpreted as inclusive in the lower and upper bound.uniformRM (1 :: Int, 4 :: Int). generates values uniformly from the set  \{1,2,3,4\}"uniformRM (1 :: Float, 4 :: Float). generates values uniformly from the set \{x\;|\;1 \le x \le 4\}The following law should hold to make the function always defined: #uniformRM (a, b) = uniformRM (b, a)randomThe class of types for which a uniformly distributed value can be drawn from all possible values of the type.randomGenerates a value uniformly distributed over all possible values of that type.&There is a default implementation via :%:set -XDeriveGeneric -XDeriveAnyClassimport GHC.Generics (Generic)import System.Random.Statefuldata MyBool = MyTrue | MyFalse deriving (Show, Generic, Finite, Uniform)data Action = Code MyBool | Eat (Maybe Bool) | Sleep deriving (Show, Generic, Finite, Uniform)gen <- newIOGenM (mkStdGen 42)"uniformListM 10 gen :: IO [Action][Code MyTrue,Code MyTrue,Eat Nothing,Code MyFalse,Eat (Just False),Eat (Just True),Eat Nothing,Eat (Just False),Sleep,Code MyFalse]random,The standard pseudo-random number generator.randomWrapper for pure state gen, which acts as an immutable seed for the corresponding stateful generator  randomOpaque data type that carries the type of a pure pseudo-random number generator. randomThis class is designed for stateful pseudo-random number generators that can be saved as and restored from an immutable data type. randomRepresents the state of the pseudo-random number generator for use with  and  . randomSaves the state of the pseudo-random number generator as a frozen seed.randomRestores the pseudo-random number generator from its frozen seed.random< is an interface to monadic pseudo-random number generators.randomuniformWord32R upperBound g generates a / that is uniformly distributed over the range [0, upperBound].randomuniformWord64R upperBound g generates a / that is uniformly distributed over the range [0, upperBound].random Generates a / that is uniformly distributed over the entire  range.&The default implementation extracts a  from .random Generates a 0 that is uniformly distributed over the entire  range.&The default implementation extracts a  from .random Generates a 0 that is uniformly distributed over the entire  range.&The default implementation extracts a  from .random Generates a 0 that is uniformly distributed over the entire  range.(The default implementation combines two  from  into one .randomuniformShortByteString n g generates a  of length n" filled with pseudo-random bytes.random9 is an interface to pure pseudo-random number generators. is the standard # instance provided by this library.random Returns an ; that is uniformly distributed over the range returned by  9 (including both end points), and a new generator. Using * is inefficient as all operations go via . See  =https://alexey.kuleshevi.ch/blog/2019/12/21/random-benchmarkshere* for more details. It is thus deprecated.random Returns a / that is uniformly distributed over the entire  range.random Returns a / that is uniformly distributed over the entire  range.random Returns a / that is uniformly distributed over the entire  range.random Returns a / that is uniformly distributed over the entire  range.randomgenWord32R upperBound g returns a / that is uniformly distributed over the range [0, upperBound].randomgenWord64R upperBound g returns a / that is uniformly distributed over the range [0, upperBound].randomgenShortByteString n g returns a  of length n" filled with pseudo-random bytes. random'Yields the range of values returned by .It is required that:If  (a, b) =   g, then a < b.  must not examine its argument so the value it returns is determined only by the instance of ./The default definition spans the full range of .!random5Returns two distinct pseudo-random number generators.Implementations should take care to ensure that the resulting generators are not correlated. Some pseudo-random number generators are not splittable. In that case, the !0 implementation should fail with a descriptive  message."randomEfficiently generates a sequence of pseudo-random bytes in a platform independent manner.#randomSame as ", but runs in .$randomGenerates a pseudo-random  of the specified size.randomSplits a pseudo-random number generator into two. Updates the state with one of the resulting generators and returns the other.%random(Runs a monadic generating action in the 4 monad using a pure pseudo-random number generator.Examplesimport System.Random.Statefullet pureGen = mkStdGen 137,runStateGen pureGen randomM :: (Int, StdGen)(7879794327570578227,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})&random(Runs a monadic generating action in the  monad using a pure pseudo-random number generator. Returns only the resulting pseudo-random value.Examplesimport System.Random.Statefullet pureGen = mkStdGen 137#runStateGen_ pureGen randomM :: Int7879794327570578227'random(Runs a monadic generating action in the 4 monad using a pure pseudo-random number generator.Examplesimport System.Random.Statefullet pureGen = mkStdGen 1370runStateGenT pureGen randomM :: IO (Int, StdGen)(7879794327570578227,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})(random(Runs a monadic generating action in the  monad using a pure pseudo-random number generator. Returns only the resulting pseudo-random value.Examplesimport System.Random.Statefullet pureGen = mkStdGen 137'runStateGenT_ pureGen randomM :: IO Int7879794327570578227)random(Runs a monadic generating action in the 4 monad using a pure pseudo-random number generator.*random(Runs a monadic generating action in the = monad using a pure pseudo-random number generator. Same as )(, but discards the resulting generator.+random Constructs a  deterministically.randomGlobal mutable veriable with ,randomA definition of  for 0 types. If your data has several fields of sub- cardinality, this instance may be more efficient than one, derived via  and .%:set -XDeriveGeneric -XDeriveAnyClassimport GHC.Generics (Generic)import System.Random.Statefuldata Triple = Triple Word8 Word8 Word8 deriving (Show, Generic, Finite):instance Uniform Triple where uniformM = uniformViaFiniteMgen <- newIOGenM (mkStdGen 42)!uniformListM 5 gen :: IO [Triple][Triple 60 226 48,Triple 234 194 151,Triple 112 96 95,Triple 51 251 15,Triple 6 0 208]-random Generates uniformly distributed  in the range [0, 1]1. Numbers are generated by generating uniform  and dividing it by 2^{64}. It's used to implement  instance for ..random Generates uniformly distributed  in the range (0, 1]. Number is generated as )2^{-64}/2+\operatorname{uniformDouble01M}. Constant is 1/2 of smallest nonzero value which could be generated by -./random Generates uniformly distributed  in the range [0, 1]1. Numbers are generated by generating uniform  and dividing it by 2^{32}. It's used to implement  instance for .0random Generates uniformly distributed  in the range (0, 1]. Number is generated as (2^{-32}/2+\operatorname{uniformFloat01M}. Constant is 1/2 of smallest nonzero value which could be generated by /.1random Generates uniformly distributed . One can use it to define a  instance: data Colors = Red | Green | Blue deriving (Enum, Bounded) instance Uniform Colors where uniformM = uniformEnumM2random Generates uniformly distributed 1 in the given range. One can use it to define a  instance: data Colors = Red | Green | Blue deriving (Enum) instance UniformRange Colors where uniformRM = uniformEnumRM inInRange (lo, hi) x = isInRange (fromEnum lo, fromEnum hi) (fromEnum x)randomSee  %System-Random-Stateful.html#fpcaveatsFloating point number caveats.randomSee  %System-Random-Stateful.html#fpcaveatsFloating point number caveats.randomSee  %System-Random-Stateful.html#fpcaveatsFloating point number caveats.randomSee  %System-Random-Stateful.html#fpcaveatsFloating point number caveats."randomNumber of bytes to generaterandom4IO action that can generate 8 random bytes at a time6 ! "#$%&'()*+,-./012"(c) The University of Glasgow 2001;BSD-style (see the file LICENSE in the 'random' repository)libraries@haskell.orgstable Trustworthy9G3randomThe class of types for which random values can be generated. Most instances of 3 will produce values that are uniformly distributed on the full range, but for those types without a well-defined "full range" some sensible default subrange will be selected.3 exists primarily for backwards compatibility with version 1.1 of this library. In new code, use the better specified  and  instead.4randomTakes a range (lo,hi)' and a pseudo-random number generator g, and returns a pseudo-random value uniformly distributed over the closed interval [lo,hi], together with a new generator. It is unspecified what happens if lo>hi1, but usually the values will simply get swapped.let gen = mkStdGen 2021fst $ randomR ('a', 'z') gen't'fst $ randomR ('z', 'a') gen't'=For continuous types there is no requirement that the values lo and hi are ever produced, but they may be, depending on the implementation and the interval.&There is no requirement to follow the Ord instance and the concept of range can be defined on per type basis. For example product types will treat their values independently:7fst $ randomR (('a', 5.0), ('z', 10.0)) $ mkStdGen 2021('t',6.240232662366563)'In case when a lawful range is desired 9 should be used instead.5random The same as 43, but using a default range determined by the type: For bounded types (instances of  , such as +), the range is normally the whole type.For floating point types, the range is normally the closed interval [0,1].For *, the range is (arbitrarily) the range of .6randomPlural variant of 4, producing an infinite list of pseudo-random values instead of returning a new generator.7randomPlural variant of 5, producing an infinite list of pseudo-random values instead of returning a new generator.8randomGenerates a value uniformly distributed over all possible values of that type.This is a pure version of .Examplesimport System.Randomlet pureGen = mkStdGen 137!uniform pureGen :: (Bool, StdGen)(True,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})9randomGenerates a value uniformly distributed over the provided range, which is interpreted as inclusive in the lower and upper bound.uniformR (1 :: Int, 4 :: Int). generates values uniformly from the set  \{1,2,3,4\}!uniformR (1 :: Float, 4 :: Float). generates values uniformly from the set \{x\;|\;1 \le x \le 4\}The following law should hold to make the function always defined: !uniformR (a, b) = uniformR (b, a)This is a pure version of .Examplesimport System.Randomlet pureGen = mkStdGen 137%uniformR (1 :: Int, 4 :: Int) pureGen(4,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627}):random Generates a  of the specified size using a pure pseudo-random number generator. See $ for the monadic version.Examplesimport System.Randomimport Data.ByteStringlet pureGen = mkStdGen 137)unpack . fst . genByteString 10 $ pureGen![51,123,251,37,49,167,90,109,1,4];random Initialize  using system entropy (i.e.  /dev/urandom) when it is available, while falling back on using system time as the seed.<randomSets the global pseudo-random number generator. Overwrites the contents of  =randomGets the global pseudo-random number generator. Extracts the contents of  >randomApplies !0 to the current global pseudo-random generator  =, updates it with one of the results, and returns the other.?randomUses the supplied function to get a value from the current global random generator, and updates the global generator with the new generator returned by the function. For example, rollDice3 produces a pseudo-random integer between 1 and 6:(rollDice = getStdRandom (randomR (1, 6))"replicateM 10 (rollDice :: IO Int)[5,6,6,1,1,6,4,2,4,1]This is an outdated function and it is recommended to switch to its equivalent   instead, possibly with the  / if relying on the global state is acceptable.import System.Random.Stateful8rollDice = applyAtomicGen (uniformR (1, 6)) globalStdGen"replicateM 10 (rollDice :: IO Int)[4,6,1,1,4,4,3,2,1,2]@random A variant of  6 that uses the global pseudo-random number generator   randomRIO (2020, 2100) :: IO Int2040 Similar to A!, this function is equivalent to ? 4 and is included in this interface for historical reasons and backwards compatibility. It is recommended to use  instead, possibly with the  / if relying on the global state is acceptable.import System.Random.Stateful-uniformRM (2020, 2100) globalStdGen :: IO Int2079Arandom A variant of  6 that uses the global pseudo-random number generator  .import Data.IntrandomIO :: IO Int32 -1580093805This function is equivalent to ? 5 and is included in this interface for historical reasons and backwards compatibility. It is recommended to use  instead, possibly with the  / if relying on the global state is acceptable.import System.Random.Stateful!uniformM globalStdGen :: IO Int32 -1649127057BrandomNote - 4 treats a, b, c, d, e, f and g types independentlyCrandomNote - 4 treats a, b, c, d, e and f types independentlyDrandomNote - 4 treats a, b, c, d and e types independentlyErandomNote - 4 treats a, b, c and d types independentlyFrandomNote - 4 treats a, b and c types independentlyGrandomNote - 4 treats a and b types independentlyHrandomNote - 5% produces values in the closed range [0,1].IrandomNote - 5% produces values in the closed range [0,1].LrandomNote - 5% produces values in the closed range [0,1].MrandomNote - 5% produces values in the closed range [0,1].lrandomNote - 5 generates values in the  range! +3456789:;<=>?@A! 89:34567+;?=<>A@"(c) The University of Glasgow 2001;BSD-style (see the file LICENSE in the 'random' repository)libraries@haskell.orgstable Trustworthy>]=mrandomFrozen version of mutable p generatorprandomWraps a 2 that holds a pure pseudo-random number generator.srandomFrozen version of mutable v generatorvrandom Wraps an 2 that holds a pure pseudo-random number generator.v< is safe in the presence of exceptions, but not concurrency.v is slower than  & due to the extra pointer indirection.yrandomFrozen version of mutable | generator|random Wraps an 2 that holds a pure pseudo-random number generator.|< is safe in the presence of exceptions, but not concurrency.| is slower than  & due to the extra pointer indirection.| is faster than  since the  operations used by | are not atomic.?An example use case is writing pseudo-random bytes into a file:.import UnliftIO.Temporary (withSystemTempFile) import Data.ByteString (hPutStr)let ioGen g = withSystemTempFile "foo.bin" $ \_ h -> uniformRM (0, 100) g >>= flip uniformByteStringM g >>= hPutStr hand then run it:#newIOGenM (mkStdGen 1729) >>= ioGenrandomFrozen version of mutable  generatorrandom Wraps an  that holds a pure pseudo-random number generator. All operations are performed atomically.7 is safe in the presence of exceptions and concurrency. is the slowest of the monadic adapters due to the overhead of its atomic operations.randomInterface to operations on  wrappers like | and  .randomSplits a pseudo-random number generator into two. Overwrites the mutable wrapper with one of the resulting generators and returns the other.random7Runs a mutable pseudo-random number generator from its   state.Examplesimport Data.Int (Int8)withMutableGen (IOGen (mkStdGen 217)) (uniformListM 5) :: IO ([Int8], IOGen StdGen)([-74,37,-50,-2,3],IOGen {unIOGen = StdGen {unStdGen = SMGen 4273268533320920145 15251669095119325999}})randomSame as ', but only returns the generated value.Examplesimport System.Random.Statefullet pureGen = mkStdGen 137withMutableGen_ (IOGen pureGen) (uniformRM (1 :: Int, 6 :: Int))4random)Generates a list of pseudo-random values.Examplesimport System.Random.Statefullet pureGen = mkStdGen 137g <- newIOGenM pureGenuniformListM 10 g :: IO [Bool]7[True,True,True,True,False,True,True,False,False,False]random applySTGen random g)) :: (Int, StdGen)(7879794327570578227,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})random(Runs a monadic generating action in the 4 monad using a pure pseudo-random number generator.Examplesimport System.Random.Statefullet pureGen = mkStdGen 137?(runSTGen pureGen (\g -> applySTGen random g)) :: (Int, StdGen)(7879794327570578227,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})random(Runs a monadic generating action in the  monad using a pure pseudo-random number generator. Returns only the resulting pseudo-random value.Examplesimport System.Random.Statefullet pureGen = mkStdGen 1376(runSTGen_ pureGen (\g -> applySTGen random g)) :: Int7879794327570578227randomCreates a new p in .randomCreates a new p in .randomApplies a pure operation to the wrapped pseudo-random number generator.Examplesimport Control.Concurrent.STMimport System.Random.Statefulimport Data.Int (Int32)let pureGen = mkStdGen 137stmGen <- newTGenMIO pureGen1atomically $ applyTGen uniform stmGen :: IO Int32 637238067randomrandom  !"#$%&'()*+,-./0123764589:;<=>?@Amnopqrstuvwxyz{|}~  %&'()*yz{|}~stuvwxmnopqr,"#$-./012  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrsttuvvwxxyzz{||}~~    %random-1.2.1.1-4yg3wqkjsQdBr0UpSZdkxv System.RandomSystem.Random.StatefulSystem.Random.GFiniteUniformSystem.Random.InternalFiniteuniformM uniformRM globalStdGenapplyAtomicGenrandomRMrandomM UniformRangeStdGenStateGen unStateGen StateGenM FrozenGen MutableGen freezeGenthawGen StatefulGenuniformWord32RuniformWord64R uniformWord8 uniformWord16 uniformWord32 uniformWord64uniformShortByteString RandomGennextgenWord8 genWord16 genWord32 genWord64 genWord32R genWord64RgenShortByteStringgenRangesplitgenShortByteStringIOgenShortByteStringSTuniformByteStringM runStateGen runStateGen_ runStateGenT runStateGenT_ runStateGenSTrunStateGenST_mkStdGenuniformViaFiniteMuniformDouble01MuniformDoublePositive01MuniformFloat01MuniformFloatPositive01M uniformEnumM uniformEnumRMRandomrandomRrandomrandomRsrandomsuniformuniformR genByteString initStdGen setStdGen getStdGen newStdGen getStdRandom randomRIOrandomIO$fRandom(,,,,,,)$fRandom(,,,,,)$fRandom(,,,,) $fRandom(,,,) $fRandom(,,) $fRandom(,) $fRandomFloat$fRandomDouble $fRandomBool $fRandomChar$fRandomCDouble$fRandomCFloat$fRandomCUIntMax$fRandomCIntMax$fRandomCUIntPtr$fRandomCIntPtr$fRandomCULLong$fRandomCLLong$fRandomCSigAtomic$fRandomCWchar $fRandomCSize$fRandomCPtrdiff$fRandomCULong $fRandomCLong $fRandomCUInt $fRandomCInt$fRandomCUShort$fRandomCShort$fRandomCUChar$fRandomCSChar $fRandomCChar $fRandomCBool$fRandomWord64$fRandomWord32$fRandomWord16 $fRandomWord8 $fRandomWord $fRandomInt $fRandomInt64 $fRandomInt32 $fRandomInt16 $fRandomInt8$fRandomIntegerTGenunTGenTGenMunTGenMSTGenunSTGenSTGenMunSTGenMIOGenunIOGenIOGenMunIOGenM AtomicGen unAtomicGen AtomicGenM unAtomicGenM RandomGenMapplyRandomGenM splitGenMwithMutableGenwithMutableGen_ uniformListM newAtomicGenM newIOGenM applyIOGen newSTGenM applySTGenrunSTGen runSTGen_newTGenM newTGenMIO applyTGen$fRandomGenMStateGenMrm$fStatefulGenAtomicGenMm$fRandomGenMAtomicGenMrm$fFrozenGenAtomicGenm$fStatefulGenIOGenMm$fRandomGenMIOGenMrm$fFrozenGenIOGenm$fStatefulGenSTGenMST$fRandomGenMSTGenMrST$fFrozenGenSTGenST$fStatefulGenTGenMSTM$fRandomGenMTGenMrSTM$fFrozenGenTGenSTM$fEqTGen $fOrdTGen $fShowTGen$fRandomGenTGen$fStorableTGen $fNFDataTGen $fEqSTGen $fOrdSTGen $fShowSTGen$fRandomGenSTGen$fStorableSTGen $fNFDataSTGen $fEqIOGen $fOrdIOGen $fShowIOGen$fRandomGenIOGen$fStorableIOGen $fNFDataIOGen $fEqAtomicGen$fOrdAtomicGen$fShowAtomicGen$fRandomGenAtomicGen$fStorableAtomicGen$fNFDataAtomicGenbase GHC.GenericsGeneric CardinalityShift$fRealCardinalityGHC.RealIntegral$fEnumCardinalityGFinite gcardinality toGFinite fromGFinite cardinalitytoFinite fromFiniteCardGHC.WordWord32Word64Word8Word16bytestring-0.10.10.0Data.ByteString.Short.InternalShortByteStringghc-prim GHC.TypesIntinteger-wired-inGHC.Integer.TypeIntegerGHC.ErrerrorGHC.STSTData.ByteString.Internal ByteStringsplitGentransformers-0.5.6.2 Control.Monad.Trans.State.StrictStateStateT theStdGenWordGUniformDoubleFloatGHC.EnumEnum$fUniformRangeFloat$fUniformRangeDouble$fUniformRangeCDouble$fUniformRangeCFloatunStdGenBoundedChar GHC.Conc.SyncTVar GHC.STRefSTRef GHC.IORefIORefSTMIO