Skip to content

Commit

Permalink
More self-contained docs for uniform and uniformR
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousleo committed May 13, 2020
1 parent ddc5cd5 commit f2d0c78
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
21 changes: 18 additions & 3 deletions System/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions System/Random/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
--
Expand Down

0 comments on commit f2d0c78

Please sign in to comment.