-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | random number library -- -- This package provides a random number library. @package random @version 1.0.0.3 -- | This library deals with the common task of pseudo-random number -- generation. The library makes it possible to generate repeatable -- results, by starting with a specified initial random number generator, -- or to get different results on each run by using the -- system-initialised generator or by supplying a seed from some other -- source. -- -- The library is split into two layers: -- -- -- -- This implementation uses the Portable Combined Generator of L'Ecuyer -- [System.Random#LEcuyer] for 32-bit computers, transliterated by -- Lennart Augustsson. It has a period of roughly 2.30584e18. module System.Random -- | The class RandomGen provides a common interface to random -- number generators. -- -- Minimal complete definition: next and split. class RandomGen g next :: RandomGen g => g -> (Int, g) split :: RandomGen g => g -> (g, g) genRange :: RandomGen g => g -> (Int, Int) -- | The StdGen instance of RandomGen has a genRange -- of at least 30 bits. -- -- The result of repeatedly using next should be at least as -- statistically robust as the Minimal Standard Random Number -- Generator described by [System.Random#Park, -- System.Random#Carta]. Until more is known about implementations -- of split, all we require is that split deliver -- generators that are (a) not identical and (b) independently robust in -- the sense just given. -- -- The Show and Read instances of StdGen provide a -- primitive way to save the state of a random number generator. It is -- required that read (show g) == g. -- -- In addition, reads may be used to map an arbitrary string (not -- necessarily one produced by show) onto a value of type -- StdGen. In general, the Read instance of StdGen -- has the following properties: -- -- data StdGen -- | The function mkStdGen provides an alternative way of producing -- an initial generator, by mapping an Int into a generator. -- Again, distinct arguments should be likely to produce distinct -- generators. mkStdGen :: Int -> StdGen -- | Uses the supplied function to get a value from the current global -- random generator, and updates the global generator with the new -- generator returned by the function. For example, rollDice -- gets a random integer between 1 and 6: -- --
--   rollDice :: IO Int
--   rollDice = getStdRandom (randomR (1,6))
--   
getStdRandom :: (StdGen -> (a, StdGen)) -> IO a -- | Gets the global random number generator. getStdGen :: IO StdGen -- | Sets the global random number generator. setStdGen :: StdGen -> IO () -- | Applies split to the current global random generator, updates -- it with one of the results, and returns the other. newStdGen :: IO StdGen -- | With a source of random number supply in hand, the Random class -- allows the programmer to extract random values of a variety of types. -- -- Minimal complete definition: randomR and random. class Random a randomR :: (Random a, RandomGen g) => (a, a) -> g -> (a, g) random :: (Random a, RandomGen g) => g -> (a, g) randomRs :: (Random a, RandomGen g) => (a, a) -> g -> [a] randoms :: (Random a, RandomGen g) => g -> [a] randomRIO :: Random a => (a, a) -> IO a randomIO :: Random a => IO a instance Random Float instance Random Double instance Random Integer instance Random Bool instance Random Char instance Random Int instance Read StdGen instance Show StdGen instance RandomGen StdGen