packages feed

monadcryptorandom 0.1 → 0.2

raw patch · 2 files changed

+10/−8 lines, 2 files

Files

Control/Monad/Crypto/Random.hs view
@@ -52,7 +52,7 @@ -- Provided instances for @crandom g@ generates randoms between the bounds and between +/- 2^256 -- for Integer. -- --- The 'crandomR' function has degraded (theoretically unbounded, probabilitically decent) performance+-- The 'crandomR' function has degraded (theoretically unbounded, probabilistically decent) performance -- the closer your range size (high - low) is to 2^n (from the top). class CRandom a where     crandom   :: (CryptoRandomGen g) => g -> Either GenError (a, g)@@ -132,18 +132,20 @@ -- |CRandT is the transformer suggested for MonadCryptoRandom. newtype CRandT g m a = CRandT { unCRandT :: StateT g (ErrorT GenError m) a } deriving (MonadError GenError, Monad) +instance MonadTrans (CRandT g) where+	lift = CRandT . lift . lift+ -- |Simple users of generators can use CRand for -- quick and easy generation of randoms.  See -- below for a simple use of 'newGenIO' (from "crypto-api"), -- 'getCRandom', 'getBytes', and 'runCRandom'. ----- @---   getRandPair = do---         int <- getCRandom---         bytes <- getBytes 100---         return (int, bytes)+-- @getRandPair = do+--   int <- getCRandom+--   bytes <- getBytes 100+--   return (int, bytes) -----  func =+--  func = do --   g <- newGenIO --   case runCRand getRandPair g of --       Right ((int,bytes), g') -> useRandomVals (int,bytes)
monadcryptorandom.cabal view
@@ -1,5 +1,5 @@ name:           monadcryptorandom-version:        0.1+version:        0.2 license:        BSD3 license-file:   LICENSE copyright:      Thomas DuBuisson <thomas.dubuisson@gmail.com>