MonadRandom
Copyright(c) Brent Yorgey 2016
LicenseBSD3 (see LICENSE)
Maintainerbyorgey@gmail.com
Stabilityexperimental
Portabilitynon-portable (multi-param classes, functional dependencies, undecidable instances)
Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Random.Strict

Description

Random monads that are strict in the generator state. For a lazy version, see Control.Monad.Random.Lazy, which has the same interface.

Synopsis

The Rand monad transformer

type Rand g = RandT g Identity Source #

A random monad parameterized by the type g of the generator to carry.

The return function leaves the generator unchanged, while >>= uses the final generator of the first computation as the initial generator of the second.

liftRand Source #

Arguments

:: (g -> (a, g))

pure random transformer

-> Rand g a

equivalent generator-passing computation

Construct a random monad computation from a function. (The inverse of runRand.)

runRand Source #

Arguments

:: Rand g a

generator-passing computation to execute

-> g

initial generator

-> (a, g)

return value and final generator

Unwrap a random monad computation as a function. (The inverse of liftRand.)

evalRand Source #

Arguments

:: Rand g a

generator-passing computation to execute

-> g

initial generator

-> a

return value of the random computation

Evaluate a random computation with the given initial generator and return the final value, discarding the final generator.

execRand Source #

Arguments

:: Rand g a

generator-passing computation to execute

-> g

initial generator

-> g

final generator

Evaluate a random computation with the given initial generator and return the final generator, discarding the final value.

mapRand :: ((a, g) -> (b, g)) -> Rand g a -> Rand g b Source #

Map both the return value and final generator of a computation using the given function.

withRand :: (g -> g) -> Rand g a -> Rand g a Source #

withRand f m executes action m on a generator modified by applying f.

evalRandIO :: Rand StdGen a -> IO a Source #

Evaluate a random computation in the IO monad, splitting the global standard generator to get a new one for the computation.

The RandT monad transformer

data RandT g (m :: Type -> Type) a Source #

A random transformer monad parameterized by:

  • g - The generator.
  • m - The inner monad.

The return function leaves the generator unchanged, while >>= uses the final generator of the first computation as the initial generator of the second.

Instances

Instances details
(MonadReader r m, MonadWriter w m, MonadState s m) => MonadRWS r w s (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

(RandomGen g, Monad m) => MonadSplit g (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

getSplit :: RandT g m g Source #

MonadError e m => MonadError e (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

throwError :: e -> RandT g m a #

catchError :: RandT g m a -> (e -> RandT g m a) -> RandT g m a #

MonadReader r m => MonadReader r (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

ask :: RandT g m r #

local :: (r -> r) -> RandT g m a -> RandT g m a #

reader :: (r -> a) -> RandT g m a #

MonadState s m => MonadState s (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

get :: RandT g m s #

put :: s -> RandT g m () #

state :: (s -> (a, s)) -> RandT g m a #

MonadWriter w m => MonadWriter w (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

writer :: (a, w) -> RandT g m a #

tell :: w -> RandT g m () #

listen :: RandT g m a -> RandT g m (a, w) #

pass :: RandT g m (a, w -> w) -> RandT g m a #

MonadTrans (RandT g) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

lift :: Monad m => m a -> RandT g m a #

(Monad m, RandomGen g) => RandomGenM (RandGen g) g (RandT g m) Source #

Since: 0.5.3

Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

applyRandomGenM :: (g -> (a, g)) -> RandGen g -> RandT g m a #

(Monad m, RandomGen g) => StatefulGen (RandGen g) (RandT g m) Source #

Since: 0.5.3

Instance details

Defined in Control.Monad.Trans.Random.Strict

(Monad m, RandomGen g) => MonadInterleave (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

interleave :: RandT g m a -> RandT g m a Source #

(RandomGen g, Monad m) => MonadRandom (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

getRandomR :: Random a => (a, a) -> RandT g m a Source #

getRandom :: Random a => RandT g m a Source #

getRandomRs :: Random a => (a, a) -> RandT g m [a] Source #

getRandoms :: Random a => RandT g m [a] Source #

MonadPlus m => Alternative (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

empty :: RandT g m a #

(<|>) :: RandT g m a -> RandT g m a -> RandT g m a #

some :: RandT g m a -> RandT g m [a] #

many :: RandT g m a -> RandT g m [a] #

Monad m => Applicative (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

pure :: a -> RandT g m a #

(<*>) :: RandT g m (a -> b) -> RandT g m a -> RandT g m b #

liftA2 :: (a -> b -> c) -> RandT g m a -> RandT g m b -> RandT g m c #

(*>) :: RandT g m a -> RandT g m b -> RandT g m b #

(<*) :: RandT g m a -> RandT g m b -> RandT g m a #

Functor m => Functor (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

fmap :: (a -> b) -> RandT g m a -> RandT g m b #

(<$) :: a -> RandT g m b -> RandT g m a #

Monad m => Monad (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

(>>=) :: RandT g m a -> (a -> RandT g m b) -> RandT g m b #

(>>) :: RandT g m a -> RandT g m b -> RandT g m b #

return :: a -> RandT g m a #

MonadPlus m => MonadPlus (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

mzero :: RandT g m a #

mplus :: RandT g m a -> RandT g m a -> RandT g m a #

MonadFail m => MonadFail (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

fail :: String -> RandT g m a #

MonadFix m => MonadFix (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

mfix :: (a -> RandT g m a) -> RandT g m a #

MonadIO m => MonadIO (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

liftIO :: IO a -> RandT g m a #

MonadCont m => MonadCont (RandT g m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Methods

callCC :: ((a -> RandT g m b) -> RandT g m a) -> RandT g m a #

PrimMonad m => PrimMonad (RandT s m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

Associated Types

type PrimState (RandT s m) 
Instance details

Defined in Control.Monad.Trans.Random.Strict

type PrimState (RandT s m) = PrimState m

Methods

primitive :: (State# (PrimState (RandT s m)) -> (# State# (PrimState (RandT s m)), a #)) -> RandT s m a #

type PrimState (RandT s m) Source # 
Instance details

Defined in Control.Monad.Trans.Random.Strict

type PrimState (RandT s m) = PrimState m

liftRandT Source #

Arguments

:: (g -> m (a, g))

impure random transformer

-> RandT g m a

equivalent generator-passing computation

Construct a random monad computation from an impure function. (The inverse of runRandT.)

runRandT Source #

Arguments

:: RandT g m a

generator-passing computation to execute

-> g

initial generator

-> m (a, g)

return value and final generator

Unwrap a random monad computation as an impure function. (The inverse of liftRandT.)

evalRandT :: Monad m => RandT g m a -> g -> m a Source #

Evaluate a random computation with the given initial generator and return the final value, discarding the final generator.

execRandT :: Monad m => RandT g m a -> g -> m g Source #

Evaluate a random computation with the given initial generator and return the final generator, discarding the final value.

mapRandT :: (m (a, g) -> n (b, g)) -> RandT g m a -> RandT g n b Source #

Map both the return value and final generator of a computation using the given function.

withRandT :: forall g (m :: Type -> Type) a. (g -> g) -> RandT g m a -> RandT g m a Source #

withRandT f m executes action m on a generator modified by applying f.

evalRandTIO :: MonadIO m => RandT StdGen m a -> m a Source #

Evaluate a random computation that is embedded in the IO monad, splitting the global standard generator to get a new one for the computation.

Some convenience re-exports

genByteString :: RandomGen g => Int -> g -> (ByteString, g) #

Deprecated: In favor of uniformByteString

Generates a ByteString of the specified size using a pure pseudo-random number generator. See uniformByteStringM for the monadic version.

Examples

Expand
>>> import System.Random
>>> import Data.ByteString
>>> let pureGen = mkStdGen 137
>>> :seti -Wno-deprecations
>>> unpack . fst . genByteString 10 $ pureGen
[51,123,251,37,49,167,90,109,1,4]

Since: random-1.2.0

getStdGen :: MonadIO m => m StdGen #

Gets the global pseudo-random number generator. Extracts the contents of globalStdGen

Since: random-1.0.0

getStdRandom :: MonadIO m => (StdGen -> (a, StdGen)) -> m a #

Uses 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, rollDice produces a pseudo-random integer between 1 and 6:

>>> rollDice = getStdRandom (randomR (1, 6))
>>> replicateM 10 (rollDice :: IO Int)
[1,1,1,4,5,6,1,2,2,5]

This is an outdated function and it is recommended to switch to its equivalent applyAtomicGen instead, possibly with the globalStdGen if relying on the global state is acceptable.

>>> import System.Random.Stateful
>>> rollDice = applyAtomicGen (uniformR (1, 6)) globalStdGen
>>> replicateM 10 (rollDice :: IO Int)
[2,1,1,5,4,3,6,6,3,2]

Since: random-1.0.0

initStdGen :: MonadIO m => m StdGen #

Initialize StdGen using system entropy (i.e. /dev/urandom) when it is available, while falling back on using system time as the seed.

Since: random-1.2.1

newStdGen :: MonadIO m => m StdGen #

Applies split to the current global pseudo-random generator globalStdGen, updates it with one of the results, and returns the other.

Since: random-1.0.0

randomIO :: (Random a, MonadIO m) => m a #

A variant of randomM that uses the global pseudo-random number generator globalStdGen.

>>> import Data.Int
>>> randomIO :: IO Int32
114794456

This function is equivalent to getStdRandom random and is included in this interface for historical reasons and backwards compatibility. It is recommended to use uniformM instead, possibly with the globalStdGen if relying on the global state is acceptable.

>>> import System.Random.Stateful
>>> uniformM globalStdGen :: IO Int32
-1768545016

Since: random-1.0.0

randomRIO :: (Random a, MonadIO m) => (a, a) -> m a #

A variant of randomRM that uses the global pseudo-random number generator globalStdGen

>>> randomRIO (2020, 2100) :: IO Int
2028

Similar to randomIO, this function is equivalent to getStdRandom randomR and is included in this interface for historical reasons and backwards compatibility. It is recommended to use uniformRM instead, possibly with the globalStdGen if relying on the global state is acceptable.

>>> import System.Random.Stateful
>>> uniformRM (2020, 2100) globalStdGen :: IO Int
2044

Since: random-1.0.0

setStdGen :: MonadIO m => StdGen -> m () #

Sets the global pseudo-random number generator. Overwrites the contents of globalStdGen

Since: random-1.0.0

uniformByteString :: RandomGen g => Int -> g -> (ByteString, g) #

Generates a ByteString of the specified size using a pure pseudo-random number generator. See uniformByteStringM for the monadic version.

Examples

Expand
>>> import System.Random
>>> import Data.ByteString (unpack)
>>> let pureGen = mkStdGen 137
>>> unpack . fst $ uniformByteString 10 pureGen
[51,123,251,37,49,167,90,109,1,4]

Since: random-1.3.0

uniformFillMutableByteArray #

Arguments

:: RandomGen g 
=> MutableByteArray s

Mutable array to fill with random bytes

-> Int

Offset into a mutable array from the beginning in number of bytes. Offset will be clamped into the range between 0 and the total size of the mutable array

-> Int

Number of randomly generated bytes to write into the array. This number will be clamped between 0 and the total size of the array without the offset.

-> g 
-> ST s g 

Fill in a slice of a mutable byte array with randomly generated bytes. This function does not fail, instead it clamps the offset and number of bytes to generate into a valid range.

Since: random-1.3.0

uniformList :: (Uniform a, RandomGen g) => Int -> g -> ([a], g) #

Produce a list of the supplied length with elements generated uniformly.

See uniformListM for a stateful counterpart.

Examples

Expand
>>> let gen = mkStdGen 2023
>>> import Data.Word (Word16)
>>> uniformList 5 gen :: ([Word16], StdGen)
([56342,15850,25292,14347,13919],StdGen {unStdGen = SMGen 6446154349414395371 1920468677557965761})

Since: random-1.3.0

uniformListR :: (UniformRange a, RandomGen g) => Int -> (a, a) -> g -> ([a], g) #

Produce a list of the supplied length with elements generated uniformly.

See uniformListM for a stateful counterpart.

Examples

Expand
>>> let gen = mkStdGen 2023
>>> uniformListR 10 (20, 30) gen :: ([Int], StdGen)
([26,30,27,24,30,25,27,21,27,27],StdGen {unStdGen = SMGen 12965503083958398648 1920468677557965761})

Since: random-1.3.0

uniformRs :: (UniformRange a, RandomGen g) => (a, a) -> g -> [a] #

Produce an infinite list of pseudo-random values in a specified range. Same as uniforms, integrates nicely with list fusion. There is no way to recover the final generator, therefore either use split before calling uniformRs or use uniformListR instead.

Similar to randomRs, except it relies on UniformRange type class instead of Random.

Examples

Expand
>>> let gen = mkStdGen 2023
>>> take 5 $ uniformRs (10, 100) gen :: [Int]
[32,86,21,57,39]

Since: random-1.3.0

uniformShortByteString :: RandomGen g => Int -> g -> (ShortByteString, g) #

Same as uniformByteArray False, but for ShortByteString.

Returns a ShortByteString of length n filled with pseudo-random bytes.

Examples

Expand
>>> import System.Random
>>> import Data.ByteString.Short (unpack)
>>> let pureGen = mkStdGen 137
>>> unpack . fst $ uniformShortByteString 10 pureGen
[51,123,251,37,49,167,90,109,1,4]

Since: random-1.3.0

uniformShuffleList :: RandomGen g => [a] -> g -> ([a], g) #

Shuffle elements of a list in a uniformly random order.

Examples

Expand
>>> uniformShuffleList "ELVIS" $ mkStdGen 252
("LIVES",StdGen {unStdGen = SMGen 17676540583805057877 5302934877338729551})

Since: random-1.3.0

uniforms :: (Uniform a, RandomGen g) => g -> [a] #

Produce an infinite list of pseudo-random values. Integrates nicely with list fusion. Naturally, there is no way to recover the final generator, therefore either use split before calling uniforms or use uniformList instead.

Similar to randoms, except it relies on Uniform type class instead of Random

Examples

Expand
>>> let gen = mkStdGen 2023
>>> import Data.Word (Word16)
>>> take 5 $ uniforms gen :: [Word16]
[56342,15850,25292,14347,13919]

Since: random-1.3.0

mkStdGen :: Int -> StdGen #

Constructs a StdGen deterministically from an Int seed. See mkStdGen64 for a Word64 variant that is architecture agnostic.

mkStdGen64 :: Word64 -> StdGen #

Constructs a StdGen deterministically from a Word64 seed.

The difference between mkStdGen is that mkStdGen64 will work the same on 64-bit and 32-bit architectures, while the former can only use 32-bit of information for initializing the psuedo-random number generator on 32-bit operating systems

Since: random-1.3.0

uniformByteArray #

Arguments

:: RandomGen g 
=> Bool

Should byte array be allocated in pinned or unpinned memory.

-> Int

Number of bytes to generate

-> g

Pure pseudo-random numer generator

-> (ByteArray, g) 

Efficiently generates a sequence of pseudo-random bytes in a platform independent manner.

Since: random-1.3.0

mkSeed :: (SeedGen g, MonadFail m) => ByteArray -> m (Seed g) #

Construct a Seed from a ByteArray of expected length. Whenever ByteArray does not match the SeedSize specified by the pseudo-random generator, this function will fail.

Since: random-1.3.0

mkSeedFromByteString :: (SeedGen g, MonadFail m) => ByteString -> m (Seed g) #

Just like mkSeed, but uses ByteString as argument. Results in a memcopy of the seed.

Since: random-1.3.0

nonEmptyFromSeed :: SeedGen g => Seed g -> NonEmpty Word64 #

Convert a Seed to a list of 64bit words.

Since: random-1.3.0

nonEmptyToSeed :: SeedGen g => NonEmpty Word64 -> Seed g #

Construct a seed from a list of 64-bit words. At most SeedSize many bytes will be used.

Since: random-1.3.0

seedGenTypeName :: SeedGen g => String #

This is a function that shows the name of the generator type, which is useful for error reporting.

Since: random-1.3.0

seedSize :: SeedGen g => Int #

Get the expected size of the Seed in number bytes

Since: random-1.3.0

seedSizeProxy :: forall proxy g. SeedGen g => proxy g -> Int #

Just like seedSize, except it accepts a proxy as an argument.

Since: random-1.3.0

unSeed :: Seed g -> ByteArray #

Unwrap the Seed and get the underlying ByteArray

Since: random-1.3.0

unSeedToByteString :: Seed g -> ByteString #

Just like unSeed, but produced a ByteString. Results in a memcopy of the seed.

Since: random-1.3.0

withSeed :: SeedGen g => Seed g -> (g -> (a, g)) -> (a, Seed g) #

Helper function that allows for operating directly on the Seed, while supplying a function that uses the pseudo-random number generator that is constructed from that Seed.

Example

Expand
>>> :set -XTypeApplications
>>> import System.Random
>>> withSeed (nonEmptyToSeed (pure 2024) :: Seed StdGen) (uniform @Int)
(1039666877624726199,Seed [0xe9, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])

Since: random-1.3.0

withSeedFile :: (SeedGen g, MonadIO m) => FilePath -> (Seed g -> m (a, Seed g)) -> m a #

Read the seed from a file and use it for constructing a pseudo-random number generator. After supplied action has been applied to the constructed generator, the resulting generator will be converted back to a seed and written to the same file.

Since: random-1.3.0

withSeedM :: (SeedGen g, Functor f) => Seed g -> (g -> f (a, g)) -> f (a, Seed g) #

Same as withSeed, except it is useful with monadic computation and frozen generators.

See withSeedMutableGen for a helper that also handles seeds for mutable pseduo-random number generators.

Since: random-1.3.0

class Random a where #

The class of types for which random values can be generated. Most instances of Random 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.

Random exists primarily for backwards compatibility with version 1.1 of this library. In new code, use the better specified Uniform and UniformRange instead.

Since: random-1.0.0

Minimal complete definition

Nothing

Methods

randomR :: RandomGen g => (a, a) -> g -> (a, g) #

Takes 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>hi, but usually the values will simply get swapped.

>>> let gen = mkStdGen 26
>>> fst $ randomR ('a', 'z') gen
'z'
>>> fst $ randomR ('a', 'z') gen
'z'

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:

>>> fst $ randomR (('a', 5.0), ('z', 10.0)) $ mkStdGen 26
('z',5.22694980853051)

In case when a lawful range is desired uniformR should be used instead.

Since: random-1.0.0

default randomR :: (RandomGen g, UniformRange a) => (a, a) -> g -> (a, g) #

random :: RandomGen g => g -> (a, g) #

The same as randomR, but using a default range determined by the type:

  • For bounded types (instances of Bounded, such as Char), the range is normally the whole type.
  • For floating point types, the range is normally the closed interval [0,1].
  • For Integer, the range is (arbitrarily) the range of Int.

Since: random-1.0.0

default random :: (RandomGen g, Uniform a) => g -> (a, g) #

randomRs :: RandomGen g => (a, a) -> g -> [a] #

Plural variant of randomR, producing an infinite list of pseudo-random values instead of returning a new generator.

Since: random-1.0.0

randoms :: RandomGen g => g -> [a] #

Plural variant of random, producing an infinite list of pseudo-random values instead of returning a new generator.

Since: random-1.0.0

Instances

Instances details
Random CBool # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CBool, CBool) -> g -> (CBool, g) #

random :: RandomGen g => g -> (CBool, g) #

randomRs :: RandomGen g => (CBool, CBool) -> g -> [CBool] #

randoms :: RandomGen g => g -> [CBool] #

Random CChar # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CChar, CChar) -> g -> (CChar, g) #

random :: RandomGen g => g -> (CChar, g) #

randomRs :: RandomGen g => (CChar, CChar) -> g -> [CChar] #

randoms :: RandomGen g => g -> [CChar] #

Random CDouble #

Note - random produces values in the closed range [0,1].

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CDouble, CDouble) -> g -> (CDouble, g) #

random :: RandomGen g => g -> (CDouble, g) #

randomRs :: RandomGen g => (CDouble, CDouble) -> g -> [CDouble] #

randoms :: RandomGen g => g -> [CDouble] #

Random CFloat #

Note - random produces values in the closed range [0,1].

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CFloat, CFloat) -> g -> (CFloat, g) #

random :: RandomGen g => g -> (CFloat, g) #

randomRs :: RandomGen g => (CFloat, CFloat) -> g -> [CFloat] #

randoms :: RandomGen g => g -> [CFloat] #

Random CInt # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CInt, CInt) -> g -> (CInt, g) #

random :: RandomGen g => g -> (CInt, g) #

randomRs :: RandomGen g => (CInt, CInt) -> g -> [CInt] #

randoms :: RandomGen g => g -> [CInt] #

Random CIntMax # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CIntMax, CIntMax) -> g -> (CIntMax, g) #

random :: RandomGen g => g -> (CIntMax, g) #

randomRs :: RandomGen g => (CIntMax, CIntMax) -> g -> [CIntMax] #

randoms :: RandomGen g => g -> [CIntMax] #

Random CIntPtr # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CIntPtr, CIntPtr) -> g -> (CIntPtr, g) #

random :: RandomGen g => g -> (CIntPtr, g) #

randomRs :: RandomGen g => (CIntPtr, CIntPtr) -> g -> [CIntPtr] #

randoms :: RandomGen g => g -> [CIntPtr] #

Random CLLong # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CLLong, CLLong) -> g -> (CLLong, g) #

random :: RandomGen g => g -> (CLLong, g) #

randomRs :: RandomGen g => (CLLong, CLLong) -> g -> [CLLong] #

randoms :: RandomGen g => g -> [CLLong] #

Random CLong # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CLong, CLong) -> g -> (CLong, g) #

random :: RandomGen g => g -> (CLong, g) #

randomRs :: RandomGen g => (CLong, CLong) -> g -> [CLong] #

randoms :: RandomGen g => g -> [CLong] #

Random CPtrdiff # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CPtrdiff, CPtrdiff) -> g -> (CPtrdiff, g) #

random :: RandomGen g => g -> (CPtrdiff, g) #

randomRs :: RandomGen g => (CPtrdiff, CPtrdiff) -> g -> [CPtrdiff] #

randoms :: RandomGen g => g -> [CPtrdiff] #

Random CSChar # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CSChar, CSChar) -> g -> (CSChar, g) #

random :: RandomGen g => g -> (CSChar, g) #

randomRs :: RandomGen g => (CSChar, CSChar) -> g -> [CSChar] #

randoms :: RandomGen g => g -> [CSChar] #

Random CShort # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CShort, CShort) -> g -> (CShort, g) #

random :: RandomGen g => g -> (CShort, g) #

randomRs :: RandomGen g => (CShort, CShort) -> g -> [CShort] #

randoms :: RandomGen g => g -> [CShort] #

Random CSigAtomic # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CSigAtomic, CSigAtomic) -> g -> (CSigAtomic, g) #

random :: RandomGen g => g -> (CSigAtomic, g) #

randomRs :: RandomGen g => (CSigAtomic, CSigAtomic) -> g -> [CSigAtomic] #

randoms :: RandomGen g => g -> [CSigAtomic] #

Random CSize # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CSize, CSize) -> g -> (CSize, g) #

random :: RandomGen g => g -> (CSize, g) #

randomRs :: RandomGen g => (CSize, CSize) -> g -> [CSize] #

randoms :: RandomGen g => g -> [CSize] #

Random CUChar # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUChar, CUChar) -> g -> (CUChar, g) #

random :: RandomGen g => g -> (CUChar, g) #

randomRs :: RandomGen g => (CUChar, CUChar) -> g -> [CUChar] #

randoms :: RandomGen g => g -> [CUChar] #

Random CUInt # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUInt, CUInt) -> g -> (CUInt, g) #

random :: RandomGen g => g -> (CUInt, g) #

randomRs :: RandomGen g => (CUInt, CUInt) -> g -> [CUInt] #

randoms :: RandomGen g => g -> [CUInt] #

Random CUIntMax # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUIntMax, CUIntMax) -> g -> (CUIntMax, g) #

random :: RandomGen g => g -> (CUIntMax, g) #

randomRs :: RandomGen g => (CUIntMax, CUIntMax) -> g -> [CUIntMax] #

randoms :: RandomGen g => g -> [CUIntMax] #

Random CUIntPtr # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUIntPtr, CUIntPtr) -> g -> (CUIntPtr, g) #

random :: RandomGen g => g -> (CUIntPtr, g) #

randomRs :: RandomGen g => (CUIntPtr, CUIntPtr) -> g -> [CUIntPtr] #

randoms :: RandomGen g => g -> [CUIntPtr] #

Random CULLong # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CULLong, CULLong) -> g -> (CULLong, g) #

random :: RandomGen g => g -> (CULLong, g) #

randomRs :: RandomGen g => (CULLong, CULLong) -> g -> [CULLong] #

randoms :: RandomGen g => g -> [CULLong] #

Random CULong # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CULong, CULong) -> g -> (CULong, g) #

random :: RandomGen g => g -> (CULong, g) #

randomRs :: RandomGen g => (CULong, CULong) -> g -> [CULong] #

randoms :: RandomGen g => g -> [CULong] #

Random CUShort # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CUShort, CUShort) -> g -> (CUShort, g) #

random :: RandomGen g => g -> (CUShort, g) #

randomRs :: RandomGen g => (CUShort, CUShort) -> g -> [CUShort] #

randoms :: RandomGen g => g -> [CUShort] #

Random CWchar # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (CWchar, CWchar) -> g -> (CWchar, g) #

random :: RandomGen g => g -> (CWchar, g) #

randomRs :: RandomGen g => (CWchar, CWchar) -> g -> [CWchar] #

randoms :: RandomGen g => g -> [CWchar] #

Random Int16 # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int16, Int16) -> g -> (Int16, g) #

random :: RandomGen g => g -> (Int16, g) #

randomRs :: RandomGen g => (Int16, Int16) -> g -> [Int16] #

randoms :: RandomGen g => g -> [Int16] #

Random Int32 # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int32, Int32) -> g -> (Int32, g) #

random :: RandomGen g => g -> (Int32, g) #

randomRs :: RandomGen g => (Int32, Int32) -> g -> [Int32] #

randoms :: RandomGen g => g -> [Int32] #

Random Int64 # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int64, Int64) -> g -> (Int64, g) #

random :: RandomGen g => g -> (Int64, g) #

randomRs :: RandomGen g => (Int64, Int64) -> g -> [Int64] #

randoms :: RandomGen g => g -> [Int64] #

Random Int8 # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int8, Int8) -> g -> (Int8, g) #

random :: RandomGen g => g -> (Int8, g) #

randomRs :: RandomGen g => (Int8, Int8) -> g -> [Int8] #

randoms :: RandomGen g => g -> [Int8] #

Random Word16 # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word16, Word16) -> g -> (Word16, g) #

random :: RandomGen g => g -> (Word16, g) #

randomRs :: RandomGen g => (Word16, Word16) -> g -> [Word16] #

randoms :: RandomGen g => g -> [Word16] #

Random Word32 # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word32, Word32) -> g -> (Word32, g) #

random :: RandomGen g => g -> (Word32, g) #

randomRs :: RandomGen g => (Word32, Word32) -> g -> [Word32] #

randoms :: RandomGen g => g -> [Word32] #

Random Word64 # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word64, Word64) -> g -> (Word64, g) #

random :: RandomGen g => g -> (Word64, g) #

randomRs :: RandomGen g => (Word64, Word64) -> g -> [Word64] #

randoms :: RandomGen g => g -> [Word64] #

Random Word8 # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word8, Word8) -> g -> (Word8, g) #

random :: RandomGen g => g -> (Word8, g) #

randomRs :: RandomGen g => (Word8, Word8) -> g -> [Word8] #

randoms :: RandomGen g => g -> [Word8] #

Random Integer #

Note - random generates values in the Int range

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Integer, Integer) -> g -> (Integer, g) #

random :: RandomGen g => g -> (Integer, g) #

randomRs :: RandomGen g => (Integer, Integer) -> g -> [Integer] #

randoms :: RandomGen g => g -> [Integer] #

Random Bool # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Bool, Bool) -> g -> (Bool, g) #

random :: RandomGen g => g -> (Bool, g) #

randomRs :: RandomGen g => (Bool, Bool) -> g -> [Bool] #

randoms :: RandomGen g => g -> [Bool] #

Random Char # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Char, Char) -> g -> (Char, g) #

random :: RandomGen g => g -> (Char, g) #

randomRs :: RandomGen g => (Char, Char) -> g -> [Char] #

randoms :: RandomGen g => g -> [Char] #

Random Double #

Note - random produces values in the closed range [0,1].

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Double, Double) -> g -> (Double, g) #

random :: RandomGen g => g -> (Double, g) #

randomRs :: RandomGen g => (Double, Double) -> g -> [Double] #

randoms :: RandomGen g => g -> [Double] #

Random Float #

Note - random produces values in the closed range [0,1].

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Float, Float) -> g -> (Float, g) #

random :: RandomGen g => g -> (Float, g) #

randomRs :: RandomGen g => (Float, Float) -> g -> [Float] #

randoms :: RandomGen g => g -> [Float] #

Random Int # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Int, Int) -> g -> (Int, g) #

random :: RandomGen g => g -> (Int, g) #

randomRs :: RandomGen g => (Int, Int) -> g -> [Int] #

randoms :: RandomGen g => g -> [Int] #

Random Word # 
Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => (Word, Word) -> g -> (Word, g) #

random :: RandomGen g => g -> (Word, g) #

randomRs :: RandomGen g => (Word, Word) -> g -> [Word] #

randoms :: RandomGen g => g -> [Word] #

(Random a, Random b) => Random (a, b) #

Note - randomR treats a and b types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b), (a, b)) -> g -> ((a, b), g) #

random :: RandomGen g => g -> ((a, b), g) #

randomRs :: RandomGen g => ((a, b), (a, b)) -> g -> [(a, b)] #

randoms :: RandomGen g => g -> [(a, b)] #

(Random a, Random b, Random c) => Random (a, b, c) #

Note - randomR treats a, b and c types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b, c), (a, b, c)) -> g -> ((a, b, c), g) #

random :: RandomGen g => g -> ((a, b, c), g) #

randomRs :: RandomGen g => ((a, b, c), (a, b, c)) -> g -> [(a, b, c)] #

randoms :: RandomGen g => g -> [(a, b, c)] #

(Random a, Random b, Random c, Random d) => Random (a, b, c, d) #

Note - randomR treats a, b, c and d types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b, c, d), (a, b, c, d)) -> g -> ((a, b, c, d), g) #

random :: RandomGen g => g -> ((a, b, c, d), g) #

randomRs :: RandomGen g => ((a, b, c, d), (a, b, c, d)) -> g -> [(a, b, c, d)] #

randoms :: RandomGen g => g -> [(a, b, c, d)] #

(Random a, Random b, Random c, Random d, Random e) => Random (a, b, c, d, e) #

Note - randomR treats a, b, c, d and e types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b, c, d, e), (a, b, c, d, e)) -> g -> ((a, b, c, d, e), g) #

random :: RandomGen g => g -> ((a, b, c, d, e), g) #

randomRs :: RandomGen g => ((a, b, c, d, e), (a, b, c, d, e)) -> g -> [(a, b, c, d, e)] #

randoms :: RandomGen g => g -> [(a, b, c, d, e)] #

(Random a, Random b, Random c, Random d, Random e, Random f) => Random (a, b, c, d, e, f) #

Note - randomR treats a, b, c, d, e and f types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g => ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> g -> ((a, b, c, d, e, f), g) #

random :: RandomGen g => g -> ((a, b, c, d, e, f), g) #

randomRs :: RandomGen g => ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> g -> [(a, b, c, d, e, f)] #

randoms :: RandomGen g => g -> [(a, b, c, d, e, f)] #

(Random a, Random b, Random c, Random d, Random e, Random f, Random g) => Random (a, b, c, d, e, f, g) #

Note - randomR treats a, b, c, d, e, f and g types independently

Instance details

Defined in System.Random

Methods

randomR :: RandomGen g0 => ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> g0 -> ((a, b, c, d, e, f, g), g0) #

random :: RandomGen g0 => g0 -> ((a, b, c, d, e, f, g), g0) #

randomRs :: RandomGen g0 => ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> g0 -> [(a, b, c, d, e, f, g)] #

randoms :: RandomGen g0 => g0 -> [(a, b, c, d, e, f, g)] #

class Finite a #

A type class for data with a finite number of inhabitants. This type class is used in the default implementation of Uniform.

Users are not supposed to write instances of Finite manually. There is a default implementation in terms of Generic instead.

>>> :seti -XDeriveGeneric -XDeriveAnyClass
>>> import GHC.Generics (Generic)
>>> data MyBool = MyTrue | MyFalse deriving (Generic, Finite)
>>> data Action = Code MyBool | Eat (Maybe Bool) | Sleep deriving (Generic, Finite)

Instances

Instances details
Finite Void # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Void -> Cardinality

toFinite :: Integer -> Void

fromFinite :: Void -> Integer

Finite Int16 # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Int16 -> Cardinality

toFinite :: Integer -> Int16

fromFinite :: Int16 -> Integer

Finite Int32 # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Int32 -> Cardinality

toFinite :: Integer -> Int32

fromFinite :: Int32 -> Integer

Finite Int64 # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Int64 -> Cardinality

toFinite :: Integer -> Int64

fromFinite :: Int64 -> Integer

Finite Int8 # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Int8 -> Cardinality

toFinite :: Integer -> Int8

fromFinite :: Int8 -> Integer

Finite Word16 # 
Instance details

Defined in System.Random.GFinite

Finite Word32 # 
Instance details

Defined in System.Random.GFinite

Finite Word64 # 
Instance details

Defined in System.Random.GFinite

Finite Word8 # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Word8 -> Cardinality

toFinite :: Integer -> Word8

fromFinite :: Word8 -> Integer

Finite Ordering # 
Instance details

Defined in System.Random.GFinite

Finite () # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# () -> Cardinality

toFinite :: Integer -> ()

fromFinite :: () -> Integer

Finite Bool # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Bool -> Cardinality

toFinite :: Integer -> Bool

fromFinite :: Bool -> Integer

Finite Char # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Char -> Cardinality

toFinite :: Integer -> Char

fromFinite :: Char -> Integer

Finite Int # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Int -> Cardinality

toFinite :: Integer -> Int

fromFinite :: Int -> Integer

Finite Word # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# Word -> Cardinality

toFinite :: Integer -> Word

fromFinite :: Word -> Integer

Finite a => Finite (Maybe a) # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# (Maybe a) -> Cardinality

toFinite :: Integer -> Maybe a

fromFinite :: Maybe a -> Integer

(Finite a, Finite b) => Finite (Either a b) # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# (Either a b) -> Cardinality

toFinite :: Integer -> Either a b

fromFinite :: Either a b -> Integer

(Finite a, Finite b) => Finite (a, b) # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# (a, b) -> Cardinality

toFinite :: Integer -> (a, b)

fromFinite :: (a, b) -> Integer

(Finite a, Finite b, Finite c) => Finite (a, b, c) # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# (a, b, c) -> Cardinality

toFinite :: Integer -> (a, b, c)

fromFinite :: (a, b, c) -> Integer

(Finite a, Finite b, Finite c, Finite d) => Finite (a, b, c, d) # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# (a, b, c, d) -> Cardinality

toFinite :: Integer -> (a, b, c, d)

fromFinite :: (a, b, c, d) -> Integer

(Finite a, Finite b, Finite c, Finite d, Finite e) => Finite (a, b, c, d, e) # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# (a, b, c, d, e) -> Cardinality

toFinite :: Integer -> (a, b, c, d, e)

fromFinite :: (a, b, c, d, e) -> Integer

(Finite a, Finite b, Finite c, Finite d, Finite e, Finite f) => Finite (a, b, c, d, e, f) # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# (a, b, c, d, e, f) -> Cardinality

toFinite :: Integer -> (a, b, c, d, e, f)

fromFinite :: (a, b, c, d, e, f) -> Integer

(Finite a, Finite b, Finite c, Finite d, Finite e, Finite f, Finite g) => Finite (a, b, c, d, e, f, g) # 
Instance details

Defined in System.Random.GFinite

Methods

cardinality :: Proxy# (a, b, c, d, e, f, g) -> Cardinality

toFinite :: Integer -> (a, b, c, d, e, f, g)

fromFinite :: (a, b, c, d, e, f, g) -> Integer

class RandomGen g where #

RandomGen is an interface to pure pseudo-random number generators.

StdGen is the standard RandomGen instance provided by this library.

Since: random-1.0.0

Minimal complete definition

(genWord32 | genWord64 | next, genRange)

Methods

next :: g -> (Int, g) #

Deprecated: No longer used

Returns an Int that is uniformly distributed over the range returned by genRange (including both end points), and a new generator. Using next is inefficient as all operations go via Integer. See here for more details. It is thus deprecated.

Since: random-1.0.0

genWord8 :: g -> (Word8, g) #

Returns a Word8 that is uniformly distributed over the entire Word8 range.

Since: random-1.2.0

genWord16 :: g -> (Word16, g) #

Returns a Word16 that is uniformly distributed over the entire Word16 range.

Since: random-1.2.0

genWord32 :: g -> (Word32, g) #

Returns a Word32 that is uniformly distributed over the entire Word32 range.

Since: random-1.2.0

genWord64 :: g -> (Word64, g) #

Returns a Word64 that is uniformly distributed over the entire Word64 range.

Since: random-1.2.0

genWord32R :: Word32 -> g -> (Word32, g) #

genWord32R upperBound g returns a Word32 that is uniformly distributed over the range [0, upperBound].

Since: random-1.2.0

genWord64R :: Word64 -> g -> (Word64, g) #

genWord64R upperBound g returns a Word64 that is uniformly distributed over the range [0, upperBound].

Since: random-1.2.0

genShortByteString :: Int -> g -> (ShortByteString, g) #

Deprecated: In favor of uniformShortByteString

Same as uniformByteArray False, but for ShortByteString.

genShortByteString n g returns a ShortByteString of length n filled with pseudo-random bytes.

Note - This function will be removed from the type class in the next major release as it is no longer needed because of unsafeUniformFillMutableByteArray.

Since: random-1.2.0

unsafeUniformFillMutableByteArray #

Arguments

:: MutableByteArray s

Mutable array to fill with random bytes

-> Int

Offset into a mutable array from the beginning in number of bytes. Offset must be non-negative, but this will not be checked

-> Int

Number of randomly generated bytes to write into the array. Number of bytes must be non-negative and less then the total size of the array, minus the offset. This also will be checked.

-> g 
-> ST s g 

Fill in the supplied MutableByteArray with uniformly generated random bytes. This function is unsafe because it is not required to do any bounds checking. For a safe variant use uniformFillMutableByteArrayM instead.

Default type class implementation uses defaultUnsafeUniformFillMutableByteArray.

Since: random-1.3.0

genRange :: g -> (Int, Int) #

Deprecated: No longer used

Yields the range of values returned by next.

It is required that:

  • If (a, b) = genRange g, then a < b.
  • genRange must not examine its argument so the value it returns is determined only by the instance of RandomGen.

The default definition spans the full range of Int.

Since: random-1.0.0

split :: g -> (g, g) #

Deprecated: In favor of splitGen

Returns 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 split implementation should fail with a descriptive error message.

Since: random-1.0.0

default split :: SplitGen g => g -> (g, g) #

Instances

Instances details
RandomGen StdGen # 
Instance details

Defined in System.Random.Internal

RandomGen SMGen # 
Instance details

Defined in System.Random.Internal

RandomGen SMGen # 
Instance details

Defined in System.Random.Internal

RandomGen g => RandomGen (StateGen g) # 
Instance details

Defined in System.Random.Internal

RandomGen g => RandomGen (AtomicGen g) # 
Instance details

Defined in System.Random.Stateful

RandomGen g => RandomGen (IOGen g) # 
Instance details

Defined in System.Random.Stateful

RandomGen g => RandomGen (STGen g) # 
Instance details

Defined in System.Random.Stateful

RandomGen g => RandomGen (TGen g) # 
Instance details

Defined in System.Random.Stateful

Methods

next :: TGen g -> (Int, TGen g) #

genWord8 :: TGen g -> (Word8, TGen g) #

genWord16 :: TGen g -> (Word16, TGen g) #

genWord32 :: TGen g -> (Word32, TGen g) #

genWord64 :: TGen g -> (Word64, TGen g) #

genWord32R :: Word32 -> TGen g -> (Word32, TGen g) #

genWord64R :: Word64 -> TGen g -> (Word64, TGen g) #

genShortByteString :: Int -> TGen g -> (ShortByteString, TGen g) #

unsafeUniformFillMutableByteArray :: MutableByteArray s -> Int -> Int -> TGen g -> ST s (TGen g) #

genRange :: TGen g -> (Int, Int) #

split :: TGen g -> (TGen g, TGen g) #

data Seed g #

This is a binary form of pseudo-random number generator's state. It is designed to be safe and easy to use for input/output operations like restoring from file, transmitting over the network, etc.

Constructor is not exported, becasue it is important for implementation to enforce the invariant of the underlying byte array being of the exact same length as the generator has specified in SeedSize. Use mkSeed and unSeed to get access to the raw bytes in a safe manner.

Since: random-1.3.0

Instances

Instances details
Show (Seed g) # 
Instance details

Defined in System.Random.Internal

Methods

showsPrec :: Int -> Seed g -> ShowS #

show :: Seed g -> String #

showList :: [Seed g] -> ShowS #

Eq (Seed g) # 
Instance details

Defined in System.Random.Internal

Methods

(==) :: Seed g -> Seed g -> Bool #

(/=) :: Seed g -> Seed g -> Bool #

Ord (Seed g) # 
Instance details

Defined in System.Random.Internal

Methods

compare :: Seed g -> Seed g -> Ordering #

(<) :: Seed g -> Seed g -> Bool #

(<=) :: Seed g -> Seed g -> Bool #

(>) :: Seed g -> Seed g -> Bool #

(>=) :: Seed g -> Seed g -> Bool #

max :: Seed g -> Seed g -> Seed g #

min :: Seed g -> Seed g -> Seed g #

class RandomGen g => SplitGen g where #

Pseudo-random generators that can be split into two separate and independent psuedo-random generators should provide an instance for this type class.

Historically this functionality was included in the RandomGen type class in the split function, however, few pseudo-random generators possess this property of splittability. This lead the old split function being usually implemented in terms of error.

Since: random-1.3.0

Methods

splitGen :: g -> (g, g) #

Returns two distinct pseudo-random number generators.

Implementations should take care to ensure that the resulting generators are not correlated.

Since: random-1.3.0

Instances

Instances details
SplitGen StdGen # 
Instance details

Defined in System.Random.Internal

Methods

splitGen :: StdGen -> (StdGen, StdGen) #

SplitGen SMGen # 
Instance details

Defined in System.Random.Internal

Methods

splitGen :: SMGen -> (SMGen, SMGen) #

SplitGen SMGen # 
Instance details

Defined in System.Random.Internal

Methods

splitGen :: SMGen -> (SMGen, SMGen) #

SplitGen g => SplitGen (StateGen g) # 
Instance details

Defined in System.Random.Internal

Methods

splitGen :: StateGen g -> (StateGen g, StateGen g) #

SplitGen g => SplitGen (AtomicGen g) # 
Instance details

Defined in System.Random.Stateful

Methods

splitGen :: AtomicGen g -> (AtomicGen g, AtomicGen g) #

SplitGen g => SplitGen (IOGen g) # 
Instance details

Defined in System.Random.Stateful

Methods

splitGen :: IOGen g -> (IOGen g, IOGen g) #

SplitGen g => SplitGen (STGen g) # 
Instance details

Defined in System.Random.Stateful

Methods

splitGen :: STGen g -> (STGen g, STGen g) #

SplitGen g => SplitGen (TGen g) # 
Instance details

Defined in System.Random.Stateful

Methods

splitGen :: TGen g -> (TGen g, TGen g) #

data StdGen #

The standard pseudo-random number generator.

Instances

Instances details
NFData StdGen # 
Instance details

Defined in System.Random.Internal

Methods

rnf :: StdGen -> () #

Show StdGen # 
Instance details

Defined in System.Random.Internal

Eq StdGen # 
Instance details

Defined in System.Random.Internal

Methods

(==) :: StdGen -> StdGen -> Bool #

(/=) :: StdGen -> StdGen -> Bool #

RandomGen StdGen # 
Instance details

Defined in System.Random.Internal

SplitGen StdGen # 
Instance details

Defined in System.Random.Internal

Methods

splitGen :: StdGen -> (StdGen, StdGen) #

SeedGen StdGen # 
Instance details

Defined in System.Random.Seed

Associated Types

type SeedSize StdGen 
Instance details

Defined in System.Random.Seed

MonadSplit StdGen IO Source # 
Instance details

Defined in Control.Monad.Random.Class

type SeedSize StdGen # 
Instance details

Defined in System.Random.Seed

class Uniform a #

The class of types for which a uniformly distributed value can be drawn from all possible values of the type.

Since: random-1.2.0

Instances

Instances details
Uniform CBool # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CBool #

Uniform CChar # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CChar #

Uniform CInt # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CInt #

Uniform CIntMax # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CIntMax #

Uniform CIntPtr # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CIntPtr #

Uniform CLLong # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CLLong #

Uniform CLong # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CLong #

Uniform CPtrdiff # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CPtrdiff #

Uniform CSChar # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CSChar #

Uniform CShort # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CShort #

Uniform CSigAtomic # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CSigAtomic #

Uniform CSize # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CSize #

Uniform CUChar # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CUChar #

Uniform CUInt # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CUInt #

Uniform CUIntMax # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CUIntMax #

Uniform CUIntPtr # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CUIntPtr #

Uniform CULLong # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CULLong #

Uniform CULong # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CULong #

Uniform CUShort # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CUShort #

Uniform CWchar # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m CWchar #

Uniform Int16 # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Int16 #

Uniform Int32 # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Int32 #

Uniform Int64 # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Int64 #

Uniform Int8 # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Int8 #

Uniform Word16 # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Word16 #

Uniform Word32 # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Word32 #

Uniform Word64 # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Word64 #

Uniform Word8 # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Word8 #

Uniform () # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m () #

Uniform Bool # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Bool #

Uniform Char # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Char #

Uniform Int # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Int #

Uniform Word # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Word #

(Finite a, Uniform a) => Uniform (Maybe a) # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m (Maybe a) #

(Finite a, Uniform a, Finite b, Uniform b) => Uniform (Either a b) # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m (Either a b) #

(Uniform a, Uniform b) => Uniform (a, b) # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m (a, b) #

(Uniform a, Uniform b, Uniform c) => Uniform (a, b, c) # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m (a, b, c) #

(Uniform a, Uniform b, Uniform c, Uniform d) => Uniform (a, b, c, d) # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m (a, b, c, d) #

(Uniform a, Uniform b, Uniform c, Uniform d, Uniform e) => Uniform (a, b, c, d, e) # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m (a, b, c, d, e) #

(Uniform a, Uniform b, Uniform c, Uniform d, Uniform e, Uniform f) => Uniform (a, b, c, d, e, f) # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m (a, b, c, d, e, f) #

(Uniform a, Uniform b, Uniform c, Uniform d, Uniform e, Uniform f, Uniform g) => Uniform (a, b, c, d, e, f, g) # 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g0 m => g0 -> m (a, b, c, d, e, f, g) #

class UniformRange a #

The class of types for which a uniformly distributed value can be drawn from a range.

Since: random-1.2.0

Instances

Instances details
UniformRange CBool # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CBool, CBool) -> g -> m CBool #

isInRange :: (CBool, CBool) -> CBool -> Bool #

UniformRange CChar # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CChar, CChar) -> g -> m CChar #

isInRange :: (CChar, CChar) -> CChar -> Bool #

UniformRange CDouble #

See Floating point number caveats.

Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CDouble, CDouble) -> g -> m CDouble #

isInRange :: (CDouble, CDouble) -> CDouble -> Bool #

UniformRange CFloat #

See Floating point number caveats.

Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CFloat, CFloat) -> g -> m CFloat #

isInRange :: (CFloat, CFloat) -> CFloat -> Bool #

UniformRange CInt # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CInt, CInt) -> g -> m CInt #

isInRange :: (CInt, CInt) -> CInt -> Bool #

UniformRange CIntMax # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CIntMax, CIntMax) -> g -> m CIntMax #

isInRange :: (CIntMax, CIntMax) -> CIntMax -> Bool #

UniformRange CIntPtr # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CIntPtr, CIntPtr) -> g -> m CIntPtr #

isInRange :: (CIntPtr, CIntPtr) -> CIntPtr -> Bool #

UniformRange CLLong # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CLLong, CLLong) -> g -> m CLLong #

isInRange :: (CLLong, CLLong) -> CLLong -> Bool #

UniformRange CLong # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CLong, CLong) -> g -> m CLong #

isInRange :: (CLong, CLong) -> CLong -> Bool #

UniformRange CPtrdiff # 
Instance details

Defined in System.Random.Internal

UniformRange CSChar # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CSChar, CSChar) -> g -> m CSChar #

isInRange :: (CSChar, CSChar) -> CSChar -> Bool #

UniformRange CShort # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CShort, CShort) -> g -> m CShort #

isInRange :: (CShort, CShort) -> CShort -> Bool #

UniformRange CSigAtomic # 
Instance details

Defined in System.Random.Internal

UniformRange CSize # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CSize, CSize) -> g -> m CSize #

isInRange :: (CSize, CSize) -> CSize -> Bool #

UniformRange CUChar # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CUChar, CUChar) -> g -> m CUChar #

isInRange :: (CUChar, CUChar) -> CUChar -> Bool #

UniformRange CUInt # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CUInt, CUInt) -> g -> m CUInt #

isInRange :: (CUInt, CUInt) -> CUInt -> Bool #

UniformRange CUIntMax # 
Instance details

Defined in System.Random.Internal

UniformRange CUIntPtr # 
Instance details

Defined in System.Random.Internal

UniformRange CULLong # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CULLong, CULLong) -> g -> m CULLong #

isInRange :: (CULLong, CULLong) -> CULLong -> Bool #

UniformRange CULong # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CULong, CULong) -> g -> m CULong #

isInRange :: (CULong, CULong) -> CULong -> Bool #

UniformRange CUShort # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CUShort, CUShort) -> g -> m CUShort #

isInRange :: (CUShort, CUShort) -> CUShort -> Bool #

UniformRange CWchar # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (CWchar, CWchar) -> g -> m CWchar #

isInRange :: (CWchar, CWchar) -> CWchar -> Bool #

UniformRange Int16 # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Int16, Int16) -> g -> m Int16 #

isInRange :: (Int16, Int16) -> Int16 -> Bool #

UniformRange Int32 # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Int32, Int32) -> g -> m Int32 #

isInRange :: (Int32, Int32) -> Int32 -> Bool #

UniformRange Int64 # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Int64, Int64) -> g -> m Int64 #

isInRange :: (Int64, Int64) -> Int64 -> Bool #

UniformRange Int8 # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Int8, Int8) -> g -> m Int8 #

isInRange :: (Int8, Int8) -> Int8 -> Bool #

UniformRange Word16 # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Word16, Word16) -> g -> m Word16 #

isInRange :: (Word16, Word16) -> Word16 -> Bool #

UniformRange Word32 # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Word32, Word32) -> g -> m Word32 #

isInRange :: (Word32, Word32) -> Word32 -> Bool #

UniformRange Word64 # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Word64, Word64) -> g -> m Word64 #

isInRange :: (Word64, Word64) -> Word64 -> Bool #

UniformRange Word8 # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Word8, Word8) -> g -> m Word8 #

isInRange :: (Word8, Word8) -> Word8 -> Bool #

UniformRange Integer # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Integer, Integer) -> g -> m Integer #

isInRange :: (Integer, Integer) -> Integer -> Bool #

UniformRange Natural # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Natural, Natural) -> g -> m Natural #

isInRange :: (Natural, Natural) -> Natural -> Bool #

UniformRange () # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => ((), ()) -> g -> m () #

isInRange :: ((), ()) -> () -> Bool #

UniformRange Bool # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Bool, Bool) -> g -> m Bool #

isInRange :: (Bool, Bool) -> Bool -> Bool #

UniformRange Char # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Char, Char) -> g -> m Char #

isInRange :: (Char, Char) -> Char -> Bool #

UniformRange Double #

See Floating point number caveats.

Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Double, Double) -> g -> m Double #

isInRange :: (Double, Double) -> Double -> Bool #

UniformRange Float #

See Floating point number caveats.

Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Float, Float) -> g -> m Float #

isInRange :: (Float, Float) -> Float -> Bool #

UniformRange Int # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Int, Int) -> g -> m Int #

isInRange :: (Int, Int) -> Int -> Bool #

UniformRange Word # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Word, Word) -> g -> m Word #

isInRange :: (Word, Word) -> Word -> Bool #

(UniformRange a, UniformRange b) => UniformRange (a, b) # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => ((a, b), (a, b)) -> g -> m (a, b) #

isInRange :: ((a, b), (a, b)) -> (a, b) -> Bool #

(UniformRange a, UniformRange b, UniformRange c) => UniformRange (a, b, c) # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => ((a, b, c), (a, b, c)) -> g -> m (a, b, c) #

isInRange :: ((a, b, c), (a, b, c)) -> (a, b, c) -> Bool #

(UniformRange a, UniformRange b, UniformRange c, UniformRange d) => UniformRange (a, b, c, d) # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => ((a, b, c, d), (a, b, c, d)) -> g -> m (a, b, c, d) #

isInRange :: ((a, b, c, d), (a, b, c, d)) -> (a, b, c, d) -> Bool #

(UniformRange a, UniformRange b, UniformRange c, UniformRange d, UniformRange e) => UniformRange (a, b, c, d, e) # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => ((a, b, c, d, e), (a, b, c, d, e)) -> g -> m (a, b, c, d, e) #

isInRange :: ((a, b, c, d, e), (a, b, c, d, e)) -> (a, b, c, d, e) -> Bool #

(UniformRange a, UniformRange b, UniformRange c, UniformRange d, UniformRange e, UniformRange f) => UniformRange (a, b, c, d, e, f) # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> g -> m (a, b, c, d, e, f) #

isInRange :: ((a, b, c, d, e, f), (a, b, c, d, e, f)) -> (a, b, c, d, e, f) -> Bool #

(UniformRange a, UniformRange b, UniformRange c, UniformRange d, UniformRange e, UniformRange f, UniformRange g) => UniformRange (a, b, c, d, e, f, g) # 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g0 m => ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> g0 -> m (a, b, c, d, e, f, g) #

isInRange :: ((a, b, c, d, e, f, g), (a, b, c, d, e, f, g)) -> (a, b, c, d, e, f, g) -> Bool #

class (KnownNat (SeedSize g), 1 <= SeedSize g, Typeable g) => SeedGen g where #

Interface for converting a pure pseudo-random number generator to and from non-empty sequence of bytes. Seeds are stored in Little-Endian order regardless of the platform it is being used on, which provides cross-platform compatibility, while providing optimal performance for the most common platform type.

Conversion to and from a Seed serves as a building block for implementing serialization for any pure or frozen pseudo-random number generator.

It is not trivial to implement platform independence. For this reason this type class has two alternative ways of creating an instance for this class. The easiest way for constructing a platform indepent seed is by converting the inner state of a generator to and from a list of 64 bit words using toSeed64 and fromSeed64 respectively. In that case cross-platform support will be handled automaticaly.

>>> :set -XDataKinds -XTypeFamilies
>>> import Data.Word (Word8, Word32)
>>> import Data.Bits ((.|.), shiftR, shiftL)
>>> import Data.List.NonEmpty (NonEmpty ((:|)))
>>> data FiveByteGen = FiveByteGen Word8 Word32 deriving Show
>>> :{
instance SeedGen FiveByteGen where
  type SeedSize FiveByteGen = 5
  fromSeed64 (w64 :| _) =
    FiveByteGen (fromIntegral (w64 `shiftR` 32)) (fromIntegral w64)
  toSeed64 (FiveByteGen x1 x4) =
    let w64 = (fromIntegral x1 `shiftL` 32) .|. fromIntegral x4
     in (w64 :| [])
:}
>>> FiveByteGen 0x80 0x01020304
FiveByteGen 128 16909060
>>> fromSeed (toSeed (FiveByteGen 0x80 0x01020304))
FiveByteGen 128 16909060
>>> toSeed (FiveByteGen 0x80 0x01020304)
Seed [0x04, 0x03, 0x02, 0x01, 0x80]
>>> toSeed64 (FiveByteGen 0x80 0x01020304)
549772722948 :| []

However, when performance is of utmost importance or default handling of cross platform independence is not sufficient, then an adventurous developer can try implementing conversion into bytes directly with toSeed and fromSeed.

Properties that must hold:

> fromSeed (toSeed gen) == gen
> fromSeed64 (toSeed64 gen) == gen

Note, that there is no requirement for every Seed to roundtrip, eg. this proprty does not even hold for StdGen:

>>> let seed = nonEmptyToSeed (0xab :| [0xff00]) :: Seed StdGen
>>> seed == toSeed (fromSeed seed)
False

Since: random-1.3.0

Minimal complete definition

fromSeed, toSeed | fromSeed64, toSeed64

Associated Types

type SeedSize g :: Nat #

Number of bytes that is required for storing the full state of a pseudo-random number generator. It should be big enough to satisfy the roundtrip property:

> fromSeed (toSeed gen) == gen

Methods

fromSeed :: Seed g -> g #

Convert from a binary representation to a pseudo-random number generator

Since: random-1.3.0

toSeed :: g -> Seed g #

Convert to a binary representation of a pseudo-random number generator

Since: random-1.3.0

fromSeed64 :: NonEmpty Word64 -> g #

Construct pseudo-random number generator from a list of words. Whenever list does not have enough bytes to satisfy the SeedSize requirement, it will be padded with zeros. On the other hand when it has more than necessary, extra bytes will be dropped.

For example if SeedSize is set to 2, then only the lower 16 bits of the first element in the list will be used.

Since: random-1.3.0

toSeed64 :: g -> NonEmpty Word64 #

Convert pseudo-random number generator to a list of words

In case when SeedSize is not a multiple of 8, then the upper bits of the last word in the list will be set to zero.

Since: random-1.3.0

Instances

Instances details
SeedGen StdGen # 
Instance details

Defined in System.Random.Seed

Associated Types

type SeedSize StdGen 
Instance details

Defined in System.Random.Seed

SeedGen SMGen # 
Instance details

Defined in System.Random.Seed

Associated Types

type SeedSize SMGen 
Instance details

Defined in System.Random.Seed

type SeedSize SMGen = 16
SeedGen SMGen # 
Instance details

Defined in System.Random.Seed

Associated Types

type SeedSize SMGen 
Instance details

Defined in System.Random.Seed

type SeedSize SMGen = 8
SeedGen g => SeedGen (StateGen g) # 
Instance details

Defined in System.Random.Seed

Associated Types

type SeedSize (StateGen g) 
Instance details

Defined in System.Random.Seed

SeedGen g => SeedGen (AtomicGen g) # 
Instance details

Defined in System.Random.Stateful

Associated Types

type SeedSize (AtomicGen g) 
Instance details

Defined in System.Random.Stateful

SeedGen g => SeedGen (IOGen g) # 
Instance details

Defined in System.Random.Stateful

Associated Types

type SeedSize (IOGen g) 
Instance details

Defined in System.Random.Stateful

type SeedSize (IOGen g) = SeedSize g
SeedGen g => SeedGen (STGen g) # 
Instance details

Defined in System.Random.Stateful

Associated Types

type SeedSize (STGen g) 
Instance details

Defined in System.Random.Stateful

type SeedSize (STGen g) = SeedSize g
SeedGen g => SeedGen (TGen g) # 
Instance details

Defined in System.Random.Stateful

Associated Types

type SeedSize (TGen g) 
Instance details

Defined in System.Random.Stateful

type SeedSize (TGen g) = SeedSize g

type family SeedSize g :: Nat #

Number of bytes that is required for storing the full state of a pseudo-random number generator. It should be big enough to satisfy the roundtrip property:

> fromSeed (toSeed gen) == gen

Instances

Instances details
type SeedSize StdGen # 
Instance details

Defined in System.Random.Seed

type SeedSize SMGen # 
Instance details

Defined in System.Random.Seed

type SeedSize SMGen = 16
type SeedSize SMGen # 
Instance details

Defined in System.Random.Seed

type SeedSize SMGen = 8
type SeedSize (StateGen g) # 
Instance details

Defined in System.Random.Seed

type SeedSize (AtomicGen g) # 
Instance details

Defined in System.Random.Stateful

type SeedSize (IOGen g) # 
Instance details

Defined in System.Random.Stateful

type SeedSize (IOGen g) = SeedSize g
type SeedSize (STGen g) # 
Instance details

Defined in System.Random.Stateful

type SeedSize (STGen g) = SeedSize g
type SeedSize (TGen g) # 
Instance details

Defined in System.Random.Stateful

type SeedSize (TGen g) = SeedSize g