dice-entropy-conduit-1.0.0.3: Cryptographically secure n-sided dice via rejection sampling

CopyrightPeter Robinson 2014
LicenseLGPL
MaintainerPeter Robinson <peter.robinson@monoid.at>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

System.Random.Dice.Internal

Description

 
Synopsis

Documentation

integralToBits Source #

Arguments

:: (Integral n, Integral m) 
=> Int

minimal number of bits b

-> n

the number n

-> [m]

bit representation of n, length >= b

Converts a number to its base-2 representation (as a list of bits) and prepends zeros to ensure the minimal size.

bitsToIntegral :: Integral n => [n] -> n Source #

Convert a list of bits to an integral

extendIntegralWithBits :: Integral n => n -> [n] -> n Source #

upperBound :: Word64 Source #

Upper bound on the number of sides that a random dice can have.

getDiceRolls Source #

Arguments

:: Int

n: number of sides

-> Int

k: number of rolls

-> IO [Int] 

Generates k rolls of an n sided dice.

getRandomRs Source #

Arguments

:: (Int, Int)

(inclusive) range

-> Int

number of samples

-> IO [Int] 

Generates a list of random integer values in the specified range.

diceRolls :: Int -> Conduit Word8 IO Int Source #

Produces a stream of random integer values in the range [0,n-1], for a given n <= 2^55. This conduit needs to be attached to an entropy source such as systemEntropy.

randomRs Source #

Arguments

:: (Int, Int)

range (inclusive)

-> Conduit Word8 IO Int 

Produces a stream of random integer values within a range. This conduit needs to be attached to an entropy source such as systemEntropy.

systemEntropy :: Producer IO Word8 Source #

A source of entropy. By default, we use the getEntropy function from the entropy package, see systemEntropy.

Warning: When combining a source of entropy with other conduits, it is important that there is no "backflow" due to leftover values that are being returned to the source from the conduit. This can be done by fusing the conduit with the identity map, e.g: myEntropySrc $$ Data.Conduit.List.map id =$= myConduit

dRoll :: Word64 -> Word64 -> Word64 -> Int -> Conduit Word8 IO (Int, Int) Source #

Internal function. Should not be invoked directly.