summaryrefslogtreecommitdiff
path: root/compiler/utils/Util.lhs
diff options
context:
space:
mode:
authorPepe Iborra <mnislaih@gmail.com>2007-08-14 16:19:53 +0000
committerPepe Iborra <mnislaih@gmail.com>2007-08-14 16:19:53 +0000
commitc5ff473955ffc2c1e4de76ae3d6eb2a37f785001 (patch)
treea5c1d45d09858f27faf2229e55258de9dfab93d2 /compiler/utils/Util.lhs
parentfcd7ba21a64c12b6e0f1053892d2698ae7d29f81 (diff)
downloadhaskell-c5ff473955ffc2c1e4de76ae3d6eb2a37f785001.tar.gz
Generalize some code dealing with SrcSpan sorting
and the subspan relation, and move it to the SrcLoc module
Diffstat (limited to 'compiler/utils/Util.lhs')
-rw-r--r--compiler/utils/Util.lhs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs
index 495df8257f..e5f7023552 100644
--- a/compiler/utils/Util.lhs
+++ b/compiler/utils/Util.lhs
@@ -26,7 +26,7 @@ module Util (
nTimes,
-- sorting
- sortLe, sortWith,
+ sortLe, sortWith, on,
-- transitive closures
transitiveClosure,
@@ -457,6 +457,10 @@ sortWith :: Ord b => (a->b) -> [a] -> [a]
sortWith get_key xs = sortLe le xs
where
x `le` y = get_key x < get_key y
+
+on :: (a -> a -> Ordering) -> (b -> a) -> b -> b -> Ordering
+on cmp sel = \x y -> sel x `cmp` sel y
+
\end{code}
%************************************************************************