Skip to content

Commit

Permalink
Attempt to avoid discrepancies between Double generation and GHC vers…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
lehins committed Oct 26, 2024
1 parent 0d8caf6 commit f0339a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/System/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@ class Random a where
-- closed interval /[lo,hi]/, together with a new generator. It is unspecified
-- what happens if /lo>hi/, but usually the values will simply get swapped.
--
-- >>> let gen = mkStdGen 2021
-- >>> let gen = mkStdGen 2024
-- >>> fst $ randomR ('a', 'z') gen
-- 't'
-- >>> fst $ randomR ('z', 'a') gen
-- 't'
-- 'k'
-- >>> fst $ randomR ('a', 'z') gen
-- 'k'
--
-- For continuous types there is no requirement that the values /lo/ and /hi/ are ever
-- produced, but they may be, depending on the implementation and the interval.
Expand All @@ -353,8 +353,8 @@ class Random a where
-- defined on per type basis. For example product types will treat their values
-- independently:
--
-- >>> fst $ randomR (('a', 5.0), ('z', 10.0)) $ mkStdGen 2021
-- ('t',6.240232662366564)
-- >>> fst $ randomR (('a', 5.0), ('z', 10.0)) $ mkStdGen 2024
-- ('k',7.4063422174704625)
--
-- In case when a lawful range is desired `uniformR` should be used
-- instead.
Expand Down
6 changes: 3 additions & 3 deletions src/System/Random/Stateful.hs
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,16 @@ withMutableGen_ fg action = thawGen fg >>= action
-- ====__Examples__
--
-- >>> import System.Random.Stateful
-- >>> let pureGen = mkStdGen 137
-- >>> let pureGen = mkStdGen 138
-- >>> g <- newIOGenM pureGen
-- >>> randomM g :: IO Double
-- 0.5728354935654512
-- 0.4218547487203844
--
-- You can use type applications to disambiguate the type of the generated numbers:
--
-- >>> :seti -XTypeApplications
-- >>> randomM @Double g
-- 0.6268211351114488
-- 0.4989730462233689
--
-- @since 1.2.0
randomM :: forall a g m. (Random a, RandomGen g, FrozenGen g m) => MutableGen g m -> m a
Expand Down

0 comments on commit f0339a7

Please sign in to comment.