diff --git a/System/Random.hs b/System/Random.hs index 721ea122a..4264638cf 100644 --- a/System/Random.hs +++ b/System/Random.hs @@ -127,14 +127,29 @@ import qualified System.Random.SplitMix as SM -- See "System.Random.Monad" module -- --- | Pure version of `uniformM` that works with instances of `RandomGen` +-- | Generates a value uniformly distributed over all possible values of that +-- type. +-- +-- This is a pure version of 'System.Random.Monad.uniformM'. -- -- @since 1.2 uniform :: (RandomGen g, Uniform a) => g -> (a, g) uniform g = runGenState g uniformM - --- | Pure version of `uniformRM` that works with instances of `RandomGen` +-- | Generates a value uniformly distributed over the provided range, which +-- is interpreted as inclusive in the lower and upper bound. +-- +-- * @uniformR (1 :: Int, 4 :: Int)@ generates values uniformly from the set +-- \(\{1,2,3,4\}\) +-- +-- * @uniformR (1 :: Float, 4 :: Float)@ generates values uniformly from the +-- set \(\{x\;|\;1 \le x \le 4\}\) +-- +-- The following law should hold to make the function always defined: +-- +-- > uniformR (a, b) = uniformR (b, a) +-- +-- This is a pure version of 'System.Random.Monad.uniformRM'. -- -- @since 1.2 uniformR :: (RandomGen g, UniformRange a) => (a, a) -> g -> (a, g) diff --git a/System/Random/Internal.hs b/System/Random/Internal.hs index 76e101660..f88b08f6d 100644 --- a/System/Random/Internal.hs +++ b/System/Random/Internal.hs @@ -439,11 +439,11 @@ class UniformRange a where -- | Generates a value uniformly distributed over the provided range, which -- is interpreted as inclusive in the lower and upper bound. -- - -- * @uniformR (1 :: Int, 4 :: Int)@ should generate values uniformly from - -- the set \(\{1,2,3,4\}\) + -- * @uniformRM (1 :: Int, 4 :: Int)@ generates values uniformly from the + -- set \(\{1,2,3,4\}\) -- - -- * @uniformR (1 :: Float, 4 :: Float)@ should generate values uniformly - -- from the set \(\{x\;|\;1 \le x \le 4\}\) + -- * @uniformRM (1 :: Float, 4 :: Float)@ generates values uniformly from + -- the set \(\{x\;|\;1 \le x \le 4\}\) -- -- The following law should hold to make the function always defined: --