Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
* Change maintainer to libraries@haskell.org. For consistency with other
  libraries maintained by the Core Libraries Committee.

* Fold mkStdRNG and createStdGen into theStdGen. They were not exported from
  System.Random.

* Fix haddock warning about $intro not being defined.
  • Loading branch information
thomie committed Sep 28, 2014
1 parent cfdfe6f commit c0868a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
18 changes: 4 additions & 14 deletions System/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
module System.Random
(

-- $intro

-- * Random number generators

#ifdef ENABLE_SPLITTABLEGEN
Expand Down Expand Up @@ -255,7 +253,7 @@ 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 -- why not Integer ?
mkStdGen :: Int -> StdGen -- Haskell 98 report demands mkStdGen takes an Int.
mkStdGen s = mkStdGen32 $ fromIntegral s

{-
Expand All @@ -272,9 +270,6 @@ mkStdGen32 sMaybeNegative = StdGen (s1+1) (s2+1)
(q, s1) = s `divMod` 2147483562
s2 = q `mod` 2147483398

createStdGen :: Integer -> StdGen
createStdGen s = mkStdGen32 $ fromIntegral s

{- |
With a source of random number supply in hand, the 'Random' class allows the
programmer to extract random values of a variety of types.
Expand Down Expand Up @@ -448,12 +443,6 @@ instance Random CDouble where
-- random rng = case random rng of
-- (x,rng') -> (realToFrac (x::Double), rng')

mkStdRNG :: Integer -> IO StdGen
mkStdRNG o = do
ct <- getCPUTime
(sec, psec) <- getTime
return (createStdGen (sec * 12345 + psec + ct + o))

randomBounded :: (RandomGen g, Random a, Bounded a) => g -> (a, g)
randomBounded = randomR (minBound, maxBound)

Expand Down Expand Up @@ -564,8 +553,9 @@ getStdGen = readIORef theStdGen

theStdGen :: IORef StdGen
theStdGen = unsafePerformIO $ do
rng <- mkStdRNG 0
newIORef rng
(sec, psec) <- getTime
ct <- getCPUTime
newIORef $ mkStdGen32 $ fromInteger (sec * 12345 + psec + ct)

-- |Applies 'split' to the current global random generator,
-- updates it with one of the results, and returns the other.
Expand Down
2 changes: 1 addition & 1 deletion random.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 1.1

license: BSD3
license-file: LICENSE
maintainer: core-libraries-committee@haskell.org
maintainer: libraries@haskell.org
bug-reports: https://github.com/haskell/random/issues
synopsis: random number library
category: System
Expand Down

0 comments on commit c0868a8

Please sign in to comment.