summaryrefslogtreecommitdiff
path: root/System/Random
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-01-29 02:37:14 -0500
committerBen Sima <ben@bsima.me>2021-01-29 03:22:01 -0500
commitb289dee25ad8ce4c2622fadb2f4c31fb90914b39 (patch)
tree5511da780cdabbb98c8fbe01f03997d3263e7880 /System/Random
parent42c7614b6a4bd7504e9bf31e0882db58b85857bc (diff)
Lint 'return' into 'pure', replace bind operator
Diffstat (limited to 'System/Random')
-rw-r--r--System/Random/Shuffle.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/System/Random/Shuffle.hs b/System/Random/Shuffle.hs
index 435f083..cc587da 100644
--- a/System/Random/Shuffle.hs
+++ b/System/Random/Shuffle.hs
@@ -74,7 +74,7 @@ shuffle elements = shuffleTree (buildTree elements)
shuffleTree tree (r : rs) =
let (b, rest) = extractTree r tree in b : shuffleTree rest rs
shuffleTree _ _ = panic "[shuffle] called with lists of different lengths"
- -- Extracts the n-th element from the tree and returns
+ -- Extracts the n-th element from the tree and pures
-- that element, paired with a tree with the element
-- deleted.
-- The function maintains the invariant of the completeness
@@ -112,9 +112,9 @@ shuffle' elements len = shuffle elements <. rseq len
-- | shuffle' wrapped in a random monad
shuffleM :: (MonadRandom m) => [a] -> m [a]
shuffleM elements
- | null elements = return []
+ | null elements = pure []
| otherwise = shuffle elements <$> rseqM (length elements - 1)
where
rseqM :: (MonadRandom m) => Int -> m [Int]
- rseqM 0 = return []
+ rseqM 0 = pure []
rseqM i = liftM2 (:) (getRandomR (0, i)) (rseqM (i - 1))