diff options
Diffstat (limited to 'compiler/utils/Util.lhs')
-rw-r--r-- | compiler/utils/Util.lhs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index c5f1c0c2ed..ef36e8a9e3 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -32,6 +32,7 @@ module Util ( -- * Tuples fstOf3, sndOf3, thirdOf3, + uncurry3, -- * List operations controlled by another list takeList, dropList, splitAtList, split, @@ -44,7 +45,7 @@ module Util ( sortLe, sortWith, minWith, on, -- * Comparisons - isEqual, eqListBy, + isEqual, eqListBy, eqMaybeBy, thenCmp, cmpList, removeSpaces, @@ -208,6 +209,9 @@ thirdOf3 :: (a,b,c) -> c fstOf3 (a,_,_) = a sndOf3 (_,b,_) = b thirdOf3 (_,_,c) = c + +uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d +uncurry3 f (a, b, c) = f a b c \end{code} %************************************************************************ @@ -677,6 +681,11 @@ eqListBy _ [] [] = True eqListBy eq (x:xs) (y:ys) = eq x y && eqListBy eq xs ys eqListBy _ _ _ = False +eqMaybeBy :: (a ->a->Bool) -> Maybe a -> Maybe a -> Bool +eqMaybeBy _ Nothing Nothing = True +eqMaybeBy eq (Just x) (Just y) = eq x y +eqMaybeBy _ _ _ = False + cmpList :: (a -> a -> Ordering) -> [a] -> [a] -> Ordering -- `cmpList' uses a user-specified comparer |