random-fu-0.0.0.2: Random number generationSource codeContentsIndex
Data.Random.Source.StdGen
Synopsis
getRandomBytesFromStdGenIO :: Int -> IO [Word8]
getRandomBytesFromRandomGenRef :: (ModifyRef sr m g, RandomGen g) => sr -> Int -> m [Word8]
getRandomBytesFromRandomGenState :: (RandomGen g, MonadState g m) => Int -> m [Word8]
getRandomWordsFromRandomGenRef :: (ModifyRef sr m g, RandomGen g) => sr -> Int -> m [Word64]
getRandomWordsFromRandomGenState :: (RandomGen g, MonadState g m) => Int -> m [Word64]
Documentation
getRandomBytesFromStdGenIO :: Int -> IO [Word8]Source
getRandomBytesFromRandomGenRef :: (ModifyRef sr m g, RandomGen g) => sr -> Int -> m [Word8]Source

Given a mutable reference to a RandomGen generator, we can make a RandomSource usable in any monad in which the reference can be modified.

For example, if x :: TVar StdGen, getRandomBytesFromRandomGenRef x can be used as a RandomSource in IO, STM, or any monad which is an instance of MonadIO. It's generally probably better to use getRandomWordsFromRandomGenRef though, as this one is likely to throw away a lot of perfectly good entropy.

getRandomBytesFromRandomGenState :: (RandomGen g, MonadState g m) => Int -> m [Word8]Source
Similarly, getRandomWordsFromRandomGenState x can be used in any "state" monad in the mtl sense whose state is a RandomGen generator. Additionally, the standard mtl state monads have MonadRandom instances which do precisely that, allowing an easy conversion of RVars and other Distribution instances to "pure" random variables.
getRandomWordsFromRandomGenRef :: (ModifyRef sr m g, RandomGen g) => sr -> Int -> m [Word64]Source
See getRandomBytesFromRandomGenRef
getRandomWordsFromRandomGenState :: (RandomGen g, MonadState g m) => Int -> m [Word64]Source
See getRandomBytesFromRandomGenState
Produced by Haddock version 2.4.2