-- 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.1.0
-- | 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:
--
--
-- - A core random number generator provides a supply of bits.
-- The class RandomGen provides a common interface to such
-- generators. The library provides one instance of RandomGen, the
-- abstract data type StdGen. Programmers may, of course, supply
-- their own instances of RandomGen.
-- - The class Random provides a way to extract values of a
-- particular type from a random number generator. For example, the
-- Float instance of Random allows one to generate random
-- values of type Float.
--
--
-- 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.
class RandomGen g
next :: RandomGen g => g -> (Int, g)
genRange :: RandomGen g => g -> (Int, Int)
split :: RandomGen g => g -> (g, g)
-- | 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:
--
--
-- - It guarantees to succeed on any string.
-- - It guarantees to consume only a finite portion of the string.
-- - Different argument strings are likely to result in different
-- results.
--
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 CDouble
instance Random CFloat
instance Random Float
instance Random Double
instance Random Bool
instance Random Char
instance Random CUIntMax
instance Random CIntMax
instance Random CUIntPtr
instance Random CIntPtr
instance Random CULLong
instance Random CLLong
instance Random CSigAtomic
instance Random CWchar
instance Random CSize
instance Random CPtrdiff
instance Random CULong
instance Random CLong
instance Random CUInt
instance Random CInt
instance Random CUShort
instance Random CShort
instance Random CUChar
instance Random CSChar
instance Random CChar
instance Random Word64
instance Random Word32
instance Random Word16
instance Random Word8
instance Random Word
instance Random Int64
instance Random Int32
instance Random Int16
instance Random Int8
instance Random Int
instance Random Integer
instance Read StdGen
instance Show StdGen
instance RandomGen StdGen