- class CRandom a where
- class MonadError GenError m => MonadCryptoRandom m where
- data CRandT g m a
- type CRand g = CRandT g Identity
- runCRandT :: CRandT g m a -> g -> m (Either GenError (a, g))
- evalCRandT :: Monad m => CRandT g m a -> g -> m (Either GenError a)
- runCRand :: CRand g a -> g -> Either GenError (a, g)
- evalCRand :: CRand g a -> g -> Either GenError a
crandomR (low,high) g as typically instantiated will generate a value between
[low, high] inclusively, swapping the pair if high < low.
Provided instances for
crandom g generates randoms between the bounds and between +/- 2^256
crandomR function has degraded (theoretically unbounded, probabilitically decent) performance
the closer your range size (high - low) is to 2^n (from the top).
CRandT is the transformer suggested for MonadCryptoRandom.
getRandPair = do int <- getCRandom bytes <- getBytes 100 return (int, bytes) func = g <- newGenIO case runCRand getRandPair g of Right ((int,bytes), g') -> useRandomVals (int,bytes) Left x -> handleGenError x