=      !"#$%&'()*+,-./0123456789:;<  A Prompt; GADT describing a request for a primitive random variate. K Random variable definitions will request their entropy via these prompts, D and entropy sources will satisfy those requests. The functions in  Data.Random.Internal.TH. extend incomplete entropy-source definitions 9 to complete ones, essentially defining a very flexible # implementation-defaulting system.  Some possible future additions:  PrimFloat :: Prim Float  PrimInt :: Prim Int 3 PrimPair :: Prim a -> Prim b -> Prim (a :*: b)  PrimNormal :: Prim Double ! PrimChoice :: [(Double :*: a)] -> Prim a * PrimBytes :: !Int -> Prim ByteString EUnfortunately, I cannot get Haddock to accept my comments about the N data constructors, but hopefully they should be reasonably self-explanatory.    %This type provides a way to define a  for a monad without actually  having to declare an instance. :A source of entropy which can be used in the given monad.  See also . .Minimum implementation is either the internal  or all + other functions. Additionally, this class's interface is subject to F extension at any time, so it is very, very strongly recommended that  the  randomSource6 Template Haskell function be used to implement this J function rather than directly implementing it. That function takes care K of choosing default implementations for any missing functions; as long as @ at least one function is implemented, it will derive sensible  implementations of all others. To use  randomSource6, just wrap your instance declaration as follows (and F enable the TemplateHaskell, MultiParamTypeClasses and GADTs language G extensions, as well as any others required by your instances, such as  FlexibleInstances):  $(randomSource [d| . instance RandomSource FooM Bar where 9 {- at least one RandomSource function... -}  |]) BGenerate a random value corresponding to the specified primitive. GThis is an internal interface; use at your own risk. It may change or  disappear at any time. (Generate a uniformly distributed random = (Generate a uniformly distributed random > (Generate a uniformly distributed random ? (Generate a uniformly distributed random @ (Generate a uniformly distributed random A in the range 0 <= U < 1 (Generate a uniformly distributed random B in the range 0 <= U < 256^n FA typeclass for monads with a chosen source of entropy. For example,  RVarD is such a monad - the source from which it is (eventually) sampled J is the only source from which a random variable is permitted to draw, so H when directly requesting entropy for a random variable these functions  are used. .Minimum implementation is either the internal  or all + other functions. Additionally, this class's interface is subject to F extension at any time, so it is very, very strongly recommended that  the  monadRandom6 Template Haskell function be used to implement this J function rather than directly implementing it. That function takes care K of choosing default implementations for any missing functions; as long as @ at least one function is implemented, it will derive sensible  implementations of all others. To use  monadRandom6, just wrap your instance declaration as follows (and < enable the TemplateHaskell and GADTs language extensions):  $(monadRandom [d| ) instance MonadRandom FooM where ) getRandomDouble = return pi ( getRandomWord16 = return 4  {- etc... -}  |]) BGenerate a random value corresponding to the specified primitive. GThis is an internal interface; use at your own risk. It may change or  disappear at any time. (Generate a uniformly distributed random = (Generate a uniformly distributed random > !(Generate a uniformly distributed random ? "(Generate a uniformly distributed random @ #(Generate a uniformly distributed random A in the range 0 <= U < 1 $(Generate a uniformly distributed random B in the range 0 <= U < 256^n   !"#$   !"#$ !"#$ !"#$%A token representing the "standard" entropy source in a  P monad. Its sole purpose is to make the following true (when the types check): $ runRVar x StdRandom === sampleRVar &%&%&%&&'(Given a mutable reference to a C generator, we can make a  = usable in any monad in which the reference can be modified. See Data.Random.Source.PureMT.getRandomPrimFromMTRef for more detailed J usage hints - this function serves exactly the same purpose except for a    generator instead of a PureMT generator. D) Similarly, !getRandomWordFromRandomGenState x can be used in any "state" ) monad in the mtl sense whose state is a C generator. 2 Additionally, the standard mtl state monads have  instances 9 which do precisely that, allowing an easy conversion of RVars and  other  Distribution instances to "pure" random variables.  Again, see Data.Random.Source.PureMT.getRandomPrimFromMTState for more N detailed usage hints - this function serves exactly the same purpose except  for a   generator instead of a PureMT generator.  '() '()'() *GBuild a word out of 2 bytes. No promises are made regarding the order > in which the bytes are stuffed. Note that this means that a  RandomSource  or  MonadRandom) making use of the default definition of  getRandomWord, etc., I may return different random values on different platforms when started . with the same seed, depending on the platform's endianness. +GBuild a word out of 4 bytes. No promises are made regarding the order > in which the bytes are stuffed. Note that this means that a  RandomSource  or  MonadRandom) making use of the default definition of  getRandomWord, etc., I may return different random values on different platforms when started . with the same seed, depending on the platform's endianness. ,-GBuild a word out of 8 bytes. No promises are made regarding the order > in which the bytes are stuffed. Note that this means that a  RandomSource  or  MonadRandom) making use of the default definition of  getRandomWord, etc., I may return different random values on different platforms when started . with the same seed, depending on the platform's endianness. ./0Pack the low 23 bits from a ? into a E in the range [0,1).  Used to convert a  stdUniform ? to a  stdUniform A. 1ASame as word32ToFloat, but also return the unused bits (as the 9  least significant bits of a ?) 2Pack the low 23 bits from a @ into a E in the range [0,1).  Used to convert a  stdUniform @ to a  stdUniform A. 3@Same as wordToFloat, but also return the unused bits (as the 41  least significant bits of a @) 4Pack the low 52 bits from a @ into a A in the range [0,1).  Used to convert a  stdUniform @ to a  stdUniform A. 5Pack a ? into a A( in the range [0,1). Note that a Double's 9 mantissa is 52 bits, so this does not fill all of them. 6ASame as wordToDouble, but also return the unused bits (as the 12  least significant bits of a @) *+,-./0123456 *+,-./0123456 *+,-./0123456 ,FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno7Complete a possibly-incomplete  implementation. It is M recommended that this macro be used even if the implementation is currently  complete, as the $ class may be extended at any time. To use 76, just wrap your instance declaration as follows (and F enable the TemplateHaskell, MultiParamTypeClasses and GADTs language G extensions, as well as any others required by your instances, such as  FlexibleInstances):  $(randomSource [d| . instance RandomSource FooM Bar where 9 {- at least one RandomSource function... -}  |]) 8Complete a possibly-incomplete  implementation. It is M recommended that this macro be used even if the implementation is currently  complete, as the $ class may be extended at any time. To use 86, just wrap your instance declaration as follows (and < enable the TemplateHaskell and GADTs language extensions):  $(monadRandom [d| ) instance MonadRandom FooM where ) getRandomDouble = return pi ( getRandomWord16 = return 4  {- etc... -}  |]) 7878pq9Given a mutable reference to a  generator, we can implement  = for it in any monad in which the reference can be modified. -Typically this would be used to define a new  instance for J some new reference type or new monad in which an existing reference type J can be modified atomically. As an example, the following instance could  be used to describe how r  can be a  in the  s monad:  / instance RandomSource IO (IORef PureMT) where # supportedPrimsFrom _ _ = True 9 getSupportedRandomPrimFrom = getRandomPrimFromMTRef F(note that there is actually a more general instance declared already , covering this as a a special case, so there's no need to repeat this  declaration anywhere) )Example usage (using some functions from  Data.Random in the random-fu  package):  main = do J src <- newIORef (pureMT 1234) -- OR: newPureMT >>= newIORef 3 x <- runRVar (uniform 0 100) src :: IO Double  print x t999 !"#$78 !"#$87:On systems that have it, /dev/,random is a handy-dandy ready-to-use source B of nonsense. Keep in mind that on some systems, Linux included, /dev/random  collects "real" entropy, and if you don'$t have a good source of it, such as C special hardware for the purpose or a *lot* of network traffic, it's pretty easy M to suck the entropy pool dry with entropy-intensive applications. For many # purposes other than cryptography, /dev/&urandom is preferable because when it  runs out of real entropy it'&ll still churn out pseudorandom data. ;<uvw:;<:<;:<;;< x   ! " # $ % &''()*+,-./01234567889:;<=>?@ABCDEFGH I JKLMLNOPNOQNORNOS TUVWXYZ T[ \ 0 ( ] ^ _ ` a b c d ' e f g h i j k l m n o p q r s t u v w x y z { | } ~  N TZrandom-source-0.3Data.Random.Source.MWCData.Random.Source.PureMTData.Random.Source.StdGenData.Random.Internal.SourceData.Random.Source.StdData.Random.Internal.WordsData.Random.SourceData.Random.Source.DevRandomData.Random.Internal.PrimData.Random.Internal.THData.Random.Source.IOghc-primGHC.Prim RealWorldmersenne-random-pure64-0.2.0.3System.Random.Mersenne.Pure64 newPureMTpureMTPureMTmwc-random-0.10.0.1System.Random.MWCrestoresave initializecreateGenrandom-1.0.1.0 System.Random newStdGenmkStdGenStdGenPrimPrimNByteInteger PrimDouble PrimWord64 PrimWord32 PrimWord16 PrimWord8GetPrim RandomSourcegetRandomPrimFromgetRandomWord8FromgetRandomWord16FromgetRandomWord32FromgetRandomWord64FromgetRandomDoubleFromgetRandomNByteIntegerFrom MonadRandom getRandomPrimgetRandomWord8getRandomWord16getRandomWord32getRandomWord64getRandomDoublegetRandomNByteInteger StdRandomgetRandomPrimFromStdGenIOgetRandomPrimFromRandomGenRefgetRandomPrimFromRandomGenState buildWord16 buildWord32 buildWord32' buildWord64 buildWord64' buildWord64'' word32ToFloatword32ToFloatWithExcess wordToFloatwordToFloatWithExcess wordToDoubleword32ToDoublewordToDoubleWithExcess randomSource monadRandomgetRandomPrimFromMTRef DevRandom DevURandombaseGHC.WordWord8Word16Word32Word64 GHC.TypesDouble integer-gmpGHC.Integer.TypeInteger RandomGenatomicModifyReference'FloatContextGenericMethodGetNByteInteger GetDouble GetWord64 GetWord32 GetWord16GetWord8 allMethodsmethodNameBase methodName isMethodName nameToMethodscoreBymethod requireMethodimplementationscorecost dependsOninlinenoinlinereplacereplaceMethodName changeContext specialize stripTypeSigs addSrcParamdummygetPrimgetWord8 getWord16 getWord32 getWord64 getDoublegetNByteIntegerintIs64defaults withMTRef withMTState GHC.IORefIORefIO devRandom devURandomdev