Skip to content

Commit

Permalink
Remove biasedUniformIntegerM
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousleo committed Apr 6, 2020
1 parent 3a447b8 commit 777da65
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions System/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ module System.Random
, splitPrimGen
, applyPrimGen

-- FIXME: remove
, biasedUniformIntegerM

-- ** The global random number generator

-- $globalrng
Expand Down Expand Up @@ -1073,25 +1070,6 @@ randomIvalInteger (l,h) rng
(x,g') = next g
v' = (v * b + (fromIntegral x - fromIntegral genlo))

biasedUniformIntegerM :: (MonadRandom g m) => (Integer, Integer) -> g -> m Integer
biasedUniformIntegerM (l, h) gen
| l > h = biasedUniformIntegerM (h, l) gen
| otherwise = do
v <- f 1 0
pure (l + v `mod` k)
where
b = toInteger (maxBound :: Word64)
q = 1000
k = h - l + 1
magtgt = k * q
-- generate random values until we exceed the target magnitude
f mag v
| mag >= magtgt = pure v
| otherwise = do
x <- uniformWord64 gen
let v' = v * b + fromIntegral x
v' `seq` f (mag * b) v'

-- | Generate an 'Integer' in the range @[l, h]@ if @l <= h@ and @[h, l]@
-- otherwise.
uniformIntegerM :: (MonadRandom g m) => (Integer, Integer) -> g -> m Integer
Expand Down

0 comments on commit 777da65

Please sign in to comment.