Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generation of random numbers via Crypto.RNG.Unsafe.
Synopsis
- data RNG :: Effect where
- RandomBytes :: Int -> RNG m ByteString
- Random :: Uniform a => RNG m a
- RandomR :: UniformRange a => (a, a) -> RNG m a
- class Monad m => CryptoRNG (m :: Type -> Type) where
- randomBytes :: Int -> m ByteString
- random :: Uniform a => m a
- randomR :: UniformRange a => (a, a) -> m a
- runRNG :: IOE :> es => RNGState -> Eff (RNG ': es) a -> Eff es a
- data RNGState
- newRNGState :: MonadIO m => Int -> m RNGState
Effect
data RNG :: Effect where Source #
Provide the ability to generate random numbers.
RandomBytes :: Int -> RNG m ByteString | |
Random :: Uniform a => RNG m a | |
RandomR :: UniformRange a => (a, a) -> RNG m a |
Instances
type DispatchOf RNG Source # | |
Defined in Effectful.Crypto.RNG.Effect |
class Monad m => CryptoRNG (m :: Type -> Type) where #
Monads carrying around the RNG state.
randomBytes :: Int -> m ByteString #
Generate a given number of cryptographically secure random bytes.
Generate a cryptographically secure value uniformly distributed over all possible values of that type.
randomR :: UniformRange a => (a, a) -> m a #
Generate a cryptographically secure value in a given, closed range.
Instances
(Monad (t m), MonadTrans t, CryptoRNG m) => CryptoRNG (t m) | Generic, overlapping instance. |
Defined in Crypto.RNG.Class randomBytes :: Int -> t m ByteString # random :: Uniform a => t m a # randomR :: UniformRange a => (a, a) -> t m a # | |
MonadIO m => CryptoRNG (RNGT m) | |
Defined in Crypto.RNG.Unsafe randomBytes :: Int -> RNGT m ByteString # random :: Uniform a => RNGT m a # randomR :: UniformRange a => (a, a) -> RNGT m a # | |
MonadIO m => CryptoRNG (CryptoRNGT m) | |
Defined in Crypto.RNG randomBytes :: Int -> CryptoRNGT m ByteString # random :: Uniform a => CryptoRNGT m a # randomR :: UniformRange a => (a, a) -> CryptoRNGT m a # | |
RNG :> es => CryptoRNG (Eff es) Source # | |
Defined in Effectful.Crypto.RNG.Effect randomBytes :: Int -> Eff es ByteString # random :: Uniform a => Eff es a # randomR :: UniformRange a => (a, a) -> Eff es a # |
Handlers
runRNG :: IOE :> es => RNGState -> Eff (RNG ': es) a -> Eff es a Source #
Generate random numbers, starting with a given initial RNGState
.
Note: random numbers generated by this interpreter are not cryptographically secure and should only be used for testing purposes.