Safe Haskell | None |
---|---|
Language | Haskell98 |
Data.Random.Source.MWC
Contents
Description
This module defines the following instances:
instance RandomSource (ST s) (Gen s) instance RandomSource IO (Gen RealWorld)
Documentation
State of the pseudo-random number generator. It uses mutable state so same generator shouldn't be used from the different threads simultaneously.
Instances
RandomSource IO (Gen RealWorld) Source # | |
Defined in Data.Random.Source.MWC Methods getRandomPrimFrom :: Gen RealWorld -> Prim t -> IO t Source # getRandomWord8From :: Gen RealWorld -> IO Word8 Source # getRandomWord16From :: Gen RealWorld -> IO Word16 Source # getRandomWord32From :: Gen RealWorld -> IO Word32 Source # getRandomWord64From :: Gen RealWorld -> IO Word64 Source # getRandomDoubleFrom :: Gen RealWorld -> IO Double Source # getRandomNByteIntegerFrom :: Gen RealWorld -> Int -> IO Integer Source # | |
RandomSource (ST s) (Gen s) Source # | |
Defined in Data.Random.Source.MWC Methods getRandomPrimFrom :: Gen s -> Prim t -> ST s t Source # getRandomWord8From :: Gen s -> ST s Word8 Source # getRandomWord16From :: Gen s -> ST s Word16 Source # getRandomWord32From :: Gen s -> ST s Word32 Source # getRandomWord64From :: Gen s -> ST s Word64 Source # getRandomDoubleFrom :: Gen s -> ST s Double Source # getRandomNByteIntegerFrom :: Gen s -> Int -> ST s Integer Source # |
RealWorld
is deeply magical. It is primitive, but it is not
unlifted (hence ptrArg
). We never manipulate values of type
RealWorld
; it's only used in the type system, to parameterise State#
.
Instances
RandomSource IO (Gen RealWorld) Source # | |
Defined in Data.Random.Source.MWC Methods getRandomPrimFrom :: Gen RealWorld -> Prim t -> IO t Source # getRandomWord8From :: Gen RealWorld -> IO Word8 Source # getRandomWord16From :: Gen RealWorld -> IO Word16 Source # getRandomWord32From :: Gen RealWorld -> IO Word32 Source # getRandomWord64From :: Gen RealWorld -> IO Word64 Source # getRandomDoubleFrom :: Gen RealWorld -> IO Double Source # getRandomNByteIntegerFrom :: Gen RealWorld -> Int -> IO Integer Source # |
initialize :: (PrimMonad m, Vector v Word32) => v Word32 -> m (Gen (PrimState m)) #
Create a generator for variates using the given seed, of which up to 256 elements will be used. For arrays of less than 256 elements, part of the default seed will be used to finish initializing the generator's state.
Examples:
initialize (singleton 42)
initialize (fromList [4, 8, 15, 16, 23, 42])
If a seed contains fewer than 256 elements, it is first used
verbatim, then its elements are xor
ed against elements of the
default seed until 256 elements are reached.
If a seed contains exactly 258 elements, then the last two elements
are used to set the generator's initial state. This allows for
complete generator reproducibility, so that e.g. gen' == gen
in
the following example:
gen' <-initialize
.fromSeed
=<<save
Orphan instances
RandomSource IO (Gen RealWorld) Source # | |
Methods getRandomPrimFrom :: Gen RealWorld -> Prim t -> IO t Source # getRandomWord8From :: Gen RealWorld -> IO Word8 Source # getRandomWord16From :: Gen RealWorld -> IO Word16 Source # getRandomWord32From :: Gen RealWorld -> IO Word32 Source # getRandomWord64From :: Gen RealWorld -> IO Word64 Source # getRandomDoubleFrom :: Gen RealWorld -> IO Double Source # getRandomNByteIntegerFrom :: Gen RealWorld -> Int -> IO Integer Source # | |
RandomSource (ST s) (Gen s) Source # | |
Methods getRandomPrimFrom :: Gen s -> Prim t -> ST s t Source # getRandomWord8From :: Gen s -> ST s Word8 Source # getRandomWord16From :: Gen s -> ST s Word16 Source # getRandomWord32From :: Gen s -> ST s Word32 Source # getRandomWord64From :: Gen s -> ST s Word64 Source # getRandomDoubleFrom :: Gen s -> ST s Double Source # getRandomNByteIntegerFrom :: Gen s -> Int -> ST s Integer Source # |