Copyright | Peter Robinson 2014 |
---|---|
License | LGPL |
Maintainer | Peter Robinson <peter.robinson@monoid.at> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
- integralToBits :: (Integral n, Integral m) => Int -> n -> [m]
- bitsToIntegral :: Integral n => [n] -> n
- extendIntegralWithBits :: Integral n => n -> [n] -> n
- upperBound :: Word64
- getDiceRolls :: Int -> Int -> IO [Int]
- getRandomRs :: (Int, Int) -> Int -> IO [Int]
- diceRolls :: Int -> Conduit Word8 IO Int
- randomRs :: (Int, Int) -> Conduit Word8 IO Int
- systemEntropy :: Producer IO Word8
- dRoll :: Word64 -> Word64 -> Word64 -> Conduit Word8 IO (Int, Int)
- testPerformance :: Int -> Int -> IO ()
Documentation
:: (Integral n, Integral m) | |
=> Int | minimal number of bits |
-> n | the number |
-> [m] | bit representation of |
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
Upper bound on the number of sides that a random dice can have.
Generates k
rolls of an n
sided dice.
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
.
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 another conduits, it is
important to ensure 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 -> Conduit Word8 IO (Int, Int) Source
Internal function. Should not be invoked directly.
Compute the performance of the algorithm in terms of used random bits versus produced random values.