summaryrefslogtreecommitdiff
path: root/System/Random
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-12-30 12:24:47 -0500
committerBen Sima <ben@bsima.me>2020-12-30 12:50:09 -0500
commit9da4feb106126940264dd27925ea3c19b04aac20 (patch)
tree23a8fe41eb6ef7ef51280e598bebfbf54f851ebc /System/Random
parentf0895bfd73c53d9d5d9811c632d8e6f5e99dc0d4 (diff)
bild: build everyting
Now bild knows how to determine between modules that require ghcjs and ghc. It also knows what *not* to build, meaning it won't try to build non-buildable nix targets, for example (unfortunately this is just hardcoded for now), but it also won't build scm or py targets that I haven't implemented yet. It just silently fails, which is fine, because it means I can do `bild **/*` and everything just works. Of course, if I want to build scm code then I will have to implement that, but that's not a priority right now.
Diffstat (limited to 'System/Random')
-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