diff options
author | Ian Lynagh <igloo@earth.li> | 2012-06-22 20:48:48 +0100 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2012-06-22 20:48:48 +0100 |
commit | 0043f07ad8c9611a905379c2abd40bda0f39ebf9 (patch) | |
tree | c856147c5658860f72a49ebeea610efadb8c4062 /compiler/utils | |
parent | 585ff572a1a2b755a3d9a94700859795f62a2e87 (diff) | |
download | haskell-0043f07ad8c9611a905379c2abd40bda0f39ebf9.tar.gz |
Remove some uses of sortLe
Technically the behaviour of sortWith has changed, as it used
x `le` y = get_key x < get_key y
(note "<" rather than "<="), but I assume that that was just a mistake.
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/Digraph.lhs | 8 | ||||
-rw-r--r-- | compiler/utils/Util.lhs | 4 |
2 files changed, 5 insertions, 7 deletions
diff --git a/compiler/utils/Digraph.lhs b/compiler/utils/Digraph.lhs index f7bdff2612..9ae84a7897 100644 --- a/compiler/utils/Digraph.lhs +++ b/compiler/utils/Digraph.lhs @@ -47,7 +47,7 @@ module Digraph( ------------------------------------------------------------------------------ -import Util ( sortLe, minWith, count ) +import Util ( minWith, count ) import Outputable import Maybes ( expectJust ) import MonadUtils ( allM ) @@ -59,7 +59,8 @@ import Control.Monad.ST -- std interfaces import Data.Maybe import Data.Array -import Data.List ( (\\) ) +import Data.List hiding (transpose) +import Data.Ord import Data.Array.ST import qualified Data.Map as Map import qualified Data.Set as Set @@ -140,8 +141,7 @@ reduceNodesIntoVertices nodes key_extractor = (bounds, (!) vertex_map, key_verte max_v = length nodes - 1 bounds = (0, max_v) :: (Vertex, Vertex) - sorted_nodes = let n1 `le` n2 = (key_extractor n1 `compare` key_extractor n2) /= GT - in sortLe le nodes + sorted_nodes = sortBy (comparing key_extractor) nodes numbered_nodes = zipWith (,) [0..] sorted_nodes key_map = array bounds [(i, key_extractor node) | (i, node) <- numbered_nodes] diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 1268c52e54..b750a54354 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -569,9 +569,7 @@ sortLe :: (a->a->Bool) -> [a] -> [a] sortLe le = generalNaturalMergeSort le sortWith :: Ord b => (a->b) -> [a] -> [a] -sortWith get_key xs = sortLe le xs - where - x `le` y = get_key x < get_key y +sortWith get_key xs = sortBy (comparing get_key) xs minWith :: Ord b => (a -> b) -> [a] -> a minWith get_key xs = ASSERT( not (null xs) ) |