X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FUtil.lhs;h=8cd9e5461695aa7ee6e831f1c4e253cb198da019;hb=1525a5819aa3a6eae8d8b05cfe348a2384da0c84;hp=e692ff1aa3afcd868b7deaafcf44f9e9ea5bc39e;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index e692ff1..8cd9e54 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -12,7 +12,10 @@ module Util ( mapFst, mapSnd, mapAndUnzip, mapAndUnzip3, nOfThem, filterOut, - lengthExceeds, lengthIs, lengthAtLeast, listLengthCmp, atLength, + + lengthExceeds, lengthIs, lengthAtLeast, + listLengthCmp, atLength, equalLength, compareLength, + isSingleton, only, singleton, notNull, snocView, @@ -34,7 +37,7 @@ module Util ( takeList, dropList, splitAtList, split, -- comparisons - isEqual, eqListBy, equalLength, compareLength, + isEqual, eqListBy, thenCmp, cmpList, prefixMatch, suffixMatch, maybePrefixMatch, removeSpaces, @@ -300,6 +303,18 @@ listLengthCmp = atLength atLen atEnd atLen [] = EQ atLen _ = GT +equalLength :: [a] -> [b] -> Bool +equalLength [] [] = True +equalLength (_:xs) (_:ys) = equalLength xs ys +equalLength xs ys = False + +compareLength :: [a] -> [b] -> Ordering +compareLength [] [] = EQ +compareLength (_:xs) (_:ys) = compareLength xs ys +compareLength [] _ys = LT +compareLength _xs [] = GT + +---------------------------- singleton :: a -> [a] singleton x = [x] @@ -645,17 +660,6 @@ eqListBy eq [] [] = True eqListBy eq (x:xs) (y:ys) = eq x y && eqListBy eq xs ys eqListBy eq xs ys = False -equalLength :: [a] -> [b] -> Bool -equalLength [] [] = True -equalLength (_:xs) (_:ys) = equalLength xs ys -equalLength xs ys = False - -compareLength :: [a] -> [b] -> Ordering -compareLength [] [] = EQ -compareLength (_:xs) (_:ys) = compareLength xs ys -compareLength [] _ys = LT -compareLength _xs [] = GT - cmpList :: (a -> a -> Ordering) -> [a] -> [a] -> Ordering -- `cmpList' uses a user-specified comparer