| License | BSD-style |
|---|---|
| Maintainer | Vincent Hanquez <vincent@snarc.org> |
| Stability | stable |
| Portability | good |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.Random
Description
- data ChaChaDRG
- drgNew :: IO ChaChaDRG
- drgNewTest :: (Word64, Word64, Word64, Word64, Word64) -> ChaChaDRG
- withDRG :: DRG gen => gen -> MonadPseudoRandom gen a -> (a, gen)
- class DRG gen where
- randomBytesGenerate :: ByteArray byteArray => Int -> gen -> (byteArray, gen)
- class (Functor m, Monad m) => MonadRandom m where
- getRandomBytes :: ByteArray byteArray => Int -> m byteArray
- data MonadPseudoRandom gen a
Deterministic instances
Deterministic Random class
drgNewTest :: (Word64, Word64, Word64, Word64, Word64) -> ChaChaDRG Source
Create a new DRG from 5 Word64.
This is a convenient interface to create deterministic interface for quickcheck style testing.
It can also be used in other contexts provided the input has been properly randomly generated.
withDRG :: DRG gen => gen -> MonadPseudoRandom gen a -> (a, gen) Source
Run a pure computation with a Deterministic Random Generator
in the MonadPseudoRandom
A Deterministic Random Generator (DRG) class
Methods
randomBytesGenerate :: ByteArray byteArray => Int -> gen -> (byteArray, gen) Source
Generate N bytes of randomness from a DRG
Random abstraction
class (Functor m, Monad m) => MonadRandom m where Source
A monad constraint that allows to generate random bytes
Methods
getRandomBytes :: ByteArray byteArray => Int -> m byteArray Source
Instances
| MonadRandom IO | |
| DRG gen => MonadRandom (MonadPseudoRandom gen) |
data MonadPseudoRandom gen a Source
A simple Monad class very similar to a State Monad with the state being a DRG.
Instances
| DRG gen => Monad (MonadPseudoRandom gen) | |
| DRG gen => Functor (MonadPseudoRandom gen) | |
| DRG gen => Applicative (MonadPseudoRandom gen) | |
| DRG gen => MonadRandom (MonadPseudoRandom gen) |