Prime -> 2010
[haskell-report.git] / report / lib-hdrs / Random.hs
1 module Random (
2 RandomGen(next, split, genRange),
3 StdGen, mkStdGen,
4 Random( random, randomR,
5 randoms, randomRs,
6 randomIO, randomRIO ),
7 getStdRandom, getStdGen, setStdGen, newStdGen
8 ) where
9
10 ---------------- The RandomGen class ------------------------
11
12 class RandomGen g where
13 genRange :: g -> (Int, Int)
14 next :: g -> (Int, g)
15 split :: g -> (g, g)
16
17 ---------------- A standard instance of RandomGen -----------
18 data StdGen = ... -- Abstract
19
20 instance RandomGen StdGen where ...
21 instance Read StdGen where ...
22 instance Show StdGen where ...
23
24 mkStdGen :: Int -> StdGen
25
26 ---------------- The Random class ---------------------------
27 class Random a where
28 randomR :: RandomGen g => (a, a) -> g -> (a, g)
29 random :: RandomGen g => g -> (a, g)
30
31 randomRs :: RandomGen g => (a, a) -> g -> [a]
32 randoms :: RandomGen g => g -> [a]
33
34 randomRIO :: (a,a) -> IO a
35 randomIO :: IO a
36
37 instance Random Int where ...
38 instance Random Integer where ...
39 instance Random Float where ...
40 instance Random Double where ...
41 instance Random Bool where ...
42 instance Random Char where ...
43
44 ---------------- The global random generator ----------------
45 newStdGen :: IO StdGen
46 setStdGen :: StdGen -> IO ()
47 getStdGen :: IO StdGen
48 getStdRandom :: (StdGen -> (a, StdGen)) -> IO a
49
50