Skip to content

Commit

Permalink
Random Integer instance: use Int functions
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousleo committed Apr 7, 2020
1 parent 49947c3 commit 274d516
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions System/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,10 @@ buildRandoms cons rand = go
-- The seq fixes part of #4218 and also makes fused Core simpler.
go g = x `seq` (x `cons` go g') where (x,g') = rand g


-- Generate values in the Int range
instance Random Integer where
random g = randomR (toInteger (minBound::Int), toInteger (maxBound::Int)) g
randomM g = uniformR (toInteger (minBound::Int), toInteger (maxBound::Int)) g
random = first (toInteger :: Int -> Integer) . random
randomM = fmap (toInteger :: Int -> Integer) . randomM

instance UniformRange Integer where
uniformR = uniformIntegerM
Expand Down

0 comments on commit 274d516

Please sign in to comment.