crypto-rng-effectful-1.0.0.0: Adaptation of the crypto-rng library for the effectful ecosystem.
Safe HaskellNone
LanguageHaskell2010

Effectful.Crypto.RNG.Unsafe

Description

Generation of random numbers via Crypto.RNG.Unsafe.

Synopsis

Effect

data RNG :: Effect where Source #

Provide the ability to generate random numbers.

Constructors

RandomBytes :: Int -> RNG m ByteString 
Random :: Uniform a => RNG m a 
RandomR :: UniformRange a => (a, a) -> RNG m a 

Instances

Instances details
type DispatchOf RNG Source # 
Instance details

Defined in Effectful.Crypto.RNG.Effect

class Monad m => CryptoRNG (m :: Type -> Type) where #

Monads carrying around the RNG state.

Methods

randomBytes :: Int -> m ByteString #

Generate a given number of cryptographically secure random bytes.

random :: Uniform a => m a #

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

Instances details
(Monad (t m), MonadTrans t, CryptoRNG m) => CryptoRNG (t m)

Generic, overlapping instance.

Instance details

Defined in Crypto.RNG.Class

Methods

randomBytes :: Int -> t m ByteString #

random :: Uniform a => t m a #

randomR :: UniformRange a => (a, a) -> t m a #

MonadIO m => CryptoRNG (RNGT m) 
Instance details

Defined in Crypto.RNG.Unsafe

Methods

randomBytes :: Int -> RNGT m ByteString #

random :: Uniform a => RNGT m a #

randomR :: UniformRange a => (a, a) -> RNGT m a #

MonadIO m => CryptoRNG (CryptoRNGT m) 
Instance details

Defined in Crypto.RNG

RNG :> es => CryptoRNG (Eff es) Source # 
Instance details

Defined in Effectful.Crypto.RNG.Effect

Methods

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.

Instantiation of the initial RNG state

data RNGState #

The random number generator state.

newRNGState :: MonadIO m => Int -> m RNGState #

Create a new RNGState with a given seed.