summaryrefslogtreecommitdiff
path: root/System/Random/Shuffle.hs
diff options
context:
space:
mode:
Diffstat (limited to 'System/Random/Shuffle.hs')
-rw-r--r--System/Random/Shuffle.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/System/Random/Shuffle.hs b/System/Random/Shuffle.hs
index d26361f..435f083 100644
--- a/System/Random/Shuffle.hs
+++ b/System/Random/Shuffle.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
-- |
@@ -24,6 +26,7 @@ module System.Random.Shuffle
)
where
+import Alpha
import Control.Monad
( liftM2,
)
@@ -70,7 +73,7 @@ shuffle elements = shuffleTree (buildTree elements)
shuffleTree (Leaf e) [] = [e]
shuffleTree tree (r : rs) =
let (b, rest) = extractTree r tree in b : shuffleTree rest rs
- shuffleTree _ _ = error "[shuffle] called with lists of different lengths"
+ shuffleTree _ _ = panic "[shuffle] called with lists of different lengths"
-- Extracts the n-th element from the tree and returns
-- that element, paired with a tree with the element
-- deleted.
@@ -86,7 +89,7 @@ shuffle elements = shuffleTree (buildTree elements)
let (e, l') = extractTree n l in (e, Node (c - 1) l' r)
| otherwise =
let (e, r') = extractTree (n - cl) r in (e, Node (c - 1) l r')
- extractTree _ _ = error "[extractTree] impossible"
+ extractTree _ _ = panic "[extractTree] impossible"
-- | Given a sequence (e1,...en) to shuffle, its length, and a random
-- generator, compute the corresponding permutation of the input