Ticket #4314: SplittableGenClass.patch

File SplittableGenClass.patch, 3.2 KB (added by TomMD, 4 years ago)
Line 
11 patch for repository http://darcs.haskell.org/packages/random:
2
3Tue Sep 14 16:29:45 PDT 2010  thomas.dubuisson@gmail.com
4  * Move "split" into its own class
5
6New patches:
7
8[Move "split" into its own class
9thomas.dubuisson@gmail.com**20100914232945
10 Ignore-this: 588e2a321823c206962b77c12cdb652a
11] {
12hunk ./System/Random.hs 43
13 
14        -- * Random number generators
15 
16-         RandomGen(next, split, genRange)
17+         RandomGen(next, genRange)
18+       , SplittableGen(split)
19 
20        -- ** Standard random number generators
21        , StdGen
22hunk ./System/Random.hs 105
23 -- | The class 'RandomGen' provides a common interface to random number
24 -- generators.
25 --
26--- Minimal complete definition: 'next' and 'split'.
27+-- Minimal complete definition: 'next'.
28 
29 class RandomGen g where
30 
31hunk ./System/Random.hs 114
32    -- and a new generator.
33    next     :: g -> (Int, g)
34 
35-   -- |The 'split' operation allows one to obtain two distinct random number
36-   -- generators. This is very useful in functional programs (for example, when
37-   -- passing a random number generator down to recursive calls), but very
38-   -- little work has been done on statistically robust implementations of
39-   -- 'split' (["System.Random\#Burton", "System.Random\#Hellekalek"]
40-   -- are the only examples we know of).
41-   split    :: g -> (g, g)
42-
43    -- |The 'genRange' operation yields the range of values returned by
44    -- the generator.
45    --
46hunk ./System/Random.hs 136
47    -- default method
48    genRange _ = (minBound, maxBound)
49 
50+-- | The class 'SplittableGen' proivides a way to specify a random number
51+-- generator that can be split into two new generators.
52+class SplittableGen g where
53+   -- |The 'split' operation allows one to obtain two distinct random number
54+   -- generators. This is very useful in functional programs (for example, when
55+   -- passing a random number generator down to recursive calls), but very
56+   -- little work has been done on statistically robust implementations of
57+   -- 'split' (["System.Random\#Burton", "System.Random\#Hellekalek"]
58+   -- are the only examples we know of).
59+   split    :: g -> (g, g)
60+
61 {- |
62 The 'StdGen' instance of 'RandomGen' has a 'genRange' of at least 30 bits.
63 
64hunk ./System/Random.hs 178
65 
66 instance RandomGen StdGen where
67   next  = stdNext
68-  split = stdSplit
69   genRange _ = stdRange
70 
71hunk ./System/Random.hs 180
72+instance SplittableGen StdGen where
73+  split = stdSplit
74+
75 instance Show StdGen where
76   showsPrec p (StdGen s1 s2) =
77      showsPrec p s1 .
78}
79
80Context:
81
82[Fix randomIvalDouble so that it will not produce values more than a few ULPs below the requested lower bound
83James Cook <james.cook@usma.edu>**20100412132638
84 Ignore-this: 35a65dae123bbf5f812ebd0aac7aa3b1
85]
86[Bump version to 1.0.0.2
87Ian Lynagh <igloo@earth.li>**20090920141953]
88[use explicit import list for Data.Sequence, in preparation for an expanded interface
89Ross Paterson <ross@soi.city.ac.uk>**20090913230910
90 Ignore-this: d6f37ea56cff7c7f4edcafb89b2a9f
91]
92[Fix "Cabal check" warnings
93Ian Lynagh <igloo@earth.li>**20090811215920]
94[change dependency from old-time to time
95Laszlo Nagy <rizsotto@gmail.com>**20090709091417
96 Ignore-this: de203b243bd2f4035661c91971bd49cc
97]
98[TAG 2009-06-25
99Ian Lynagh <igloo@earth.li>**20090625160406]
100Patch bundle hash:
101aec6bb01fa1395034c0bf0c74b6bb8806922e3de