diff options
| author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-05-30 22:02:17 +0100 |
|---|---|---|
| committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-05-30 22:03:47 +0100 |
| commit | 3d81b68d48e86f9dff032321aff20b76ad3ea081 (patch) | |
| tree | d2782d570c69eae25febdb6654c8944b2435dcf3 /compiler/utils | |
| parent | 7849266ce2a9f45633d41532a07d870ea6a27fbb (diff) | |
| download | haskell-3d81b68d48e86f9dff032321aff20b76ad3ea081.tar.gz | |
Define chkAppend, and use it
Somtimes we need (xs ++ ys) in situations where ys is
almost always empty. Utils.chkAppend checks for that
case first.
Diffstat (limited to 'compiler/utils')
| -rw-r--r-- | compiler/utils/Util.lhs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 90a2077c71..e2fd0aa093 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -18,7 +18,7 @@ module Util ( unzipWith, - mapFst, mapSnd, + mapFst, mapSnd, chkAppend, mapAndUnzip, mapAndUnzip3, mapAccumL2, nOfThem, filterOut, partitionWith, splitEithers, @@ -259,6 +259,13 @@ splitEithers (e : es) = case e of Left x -> (x:xs, ys) Right y -> (xs, y:ys) where (xs,ys) = splitEithers es + +chkAppend :: [a] -> [a] -> [a] +-- Checks for the second arguemnt being empty +-- Used in situations where that situation is common +chkAppend xs ys + | null ys = xs + | otherwise = xs ++ ys \end{code} A paranoid @zip@ (and some @zipWith@ friends) that checks the lists |
