summaryrefslogtreecommitdiff
path: root/compiler/ghci
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2012-06-22 22:20:14 +0100
committerIan Lynagh <igloo@earth.li>2012-06-22 22:20:14 +0100
commitf669426401c743d3e1ea2bba0ca92ac69ec79040 (patch)
tree81d2d2b291369592ca7c60680403e68998b14090 /compiler/ghci
parentf1c81a73366ead49129e744832023335e311e066 (diff)
downloadhaskell-f669426401c743d3e1ea2bba0ca92ac69ec79040.tar.gz
Use a derived Ord instance for Discr
Our hand-written leAlt behaved differently when given a micture of constructors, but I think that either it won't make a difference or that this will be an improvement.
Diffstat (limited to 'compiler/ghci')
-rw-r--r--compiler/ghci/ByteCodeGen.lhs15
1 files changed, 3 insertions, 12 deletions
diff --git a/compiler/ghci/ByteCodeGen.lhs b/compiler/ghci/ByteCodeGen.lhs
index 0587ed6304..d722964bcd 100644
--- a/compiler/ghci/ByteCodeGen.lhs
+++ b/compiler/ghci/ByteCodeGen.lhs
@@ -66,6 +66,7 @@ import Module
import Data.Map (Map)
import qualified Data.Map as Map
import qualified FiniteMap as Map
+import Data.Ord
-- -----------------------------------------------------------------------------
-- Generating byte code for a complete module
@@ -1349,9 +1350,7 @@ mkMultiBranch maybe_ncons raw_ways = do
return (instrs `appOL` the_default)
where
(defaults, not_defaults) = partition (isNoDiscr.fst) raw_ways
- notd_ways = sortLe
- (\w1 w2 -> leAlt (fst w1) (fst w2))
- not_defaults
+ notd_ways = sortBy (comparing fst) not_defaults
testLT (DiscrI i) fail_label = TESTLT_I i fail_label
testLT (DiscrW i) fail_label = TESTLT_W i fail_label
@@ -1386,14 +1385,6 @@ mkMultiBranch maybe_ncons raw_ways = do
Just n -> (0, fromIntegral n - 1)
Nothing -> (minBound, maxBound)
- (DiscrI i1) `leAlt` (DiscrI i2) = i1 <= i2
- (DiscrW w1) `leAlt` (DiscrW w2) = w1 <= w2
- (DiscrF f1) `leAlt` (DiscrF f2) = f1 <= f2
- (DiscrD d1) `leAlt` (DiscrD d2) = d1 <= d2
- (DiscrP i1) `leAlt` (DiscrP i2) = i1 <= i2
- NoDiscr `leAlt` NoDiscr = True
- _ `leAlt` _ = False
-
isNoDiscr NoDiscr = True
isNoDiscr _ = False
@@ -1423,7 +1414,7 @@ data Discr
| DiscrD Double
| DiscrP Word16
| NoDiscr
- deriving Eq
+ deriving (Eq, Ord)
instance Outputable Discr where
ppr (DiscrI i) = int i