From 6eaaf3d8ce6025932990de6fa697d14c9651be76 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 24 Dec 2020 14:24:16 -0500 Subject: linting fixes and cleanup --- System/Random/Shuffle.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'System') diff --git a/System/Random/Shuffle.hs b/System/Random/Shuffle.hs index d3cd387..d26361f 100644 --- a/System/Random/Shuffle.hs +++ b/System/Random/Shuffle.hs @@ -16,7 +16,7 @@ -- main = do -- rng <- newStdGen -- let xs = [1,2,3,4,5] --- print $ shuffle' xs (length xs) rng +-- print <| shuffle' xs (length xs) rng module System.Random.Shuffle ( shuffle, shuffle', @@ -48,10 +48,10 @@ data Tree a -- | Convert a sequence (e1...en) to a complete binary tree buildTree :: [a] -> Tree a -buildTree = fix growLevel . map Leaf +buildTree = fix growLevel <. map Leaf where growLevel _ [node] = node - growLevel self l = self $ inner l + growLevel self l = self <| inner l inner [] = [] inner [e] = [e] inner (e1 : e2 : es) = e1 `seq` e2 `seq` join e1 e2 : inner es @@ -92,13 +92,13 @@ shuffle elements = shuffleTree (buildTree elements) -- generator, compute the corresponding permutation of the input -- sequence. shuffle' :: RandomGen gen => [a] -> Int -> gen -> [a] -shuffle' elements len = shuffle elements . rseq len +shuffle' elements len = shuffle elements <. rseq len where -- The sequence (r1,...r[n-1]) of numbers such that r[i] is an -- independent sample from a uniform random distribution -- [0..n-i] rseq :: RandomGen gen => Int -> gen -> [Int] - rseq n = map fst . rseq' (n - 1) + rseq n = map fst <. rseq' (n - 1) where rseq' :: RandomGen gen => Int -> gen -> [(Int, gen)] rseq' 0 _ = [] -- cgit v1.2.3