summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorklebinger.andreas@gmx.at <klebinger.andreas@gmx.at>2017-11-15 11:42:48 -0500
committerBen Gamari <ben@smart-cactus.org>2017-11-15 14:18:30 -0500
commite14945ce046a000f1542818cd5cb6007cf2e2422 (patch)
treecdf74a78aa2270d3a5157f8d51ce234b721e245b
parent3bed4aa703c41ccbd310496420fbb71afdfd99e7 (diff)
downloadhaskell-e14945ce046a000f1542818cd5cb6007cf2e2422.tar.gz
Adjust AltCon Ord instance to match Core linter requirements.
When sorting by the Ord instance put DEFAULT before other constructors. This is in line with what the core linter requests allowing the use of the instance for putting alternatives in the correct order. This implements #14464. Reviewers: bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #14464 Differential Revision: https://phabricator.haskell.org/D4198
-rw-r--r--compiler/coreSyn/CoreSyn.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/coreSyn/CoreSyn.hs b/compiler/coreSyn/CoreSyn.hs
index c931bf187d..1462aefb01 100644
--- a/compiler/coreSyn/CoreSyn.hs
+++ b/compiler/coreSyn/CoreSyn.hs
@@ -313,16 +313,17 @@ data AltCon
-- This instance is a bit shady. It can only be used to compare AltCons for
-- a single type constructor. Fortunately, it seems quite unlikely that we'll
-- ever need to compare AltCons for different type constructors.
+-- The instance adheres to the order described in [CoreSyn case invariants]
instance Ord AltCon where
compare (DataAlt con1) (DataAlt con2) =
ASSERT( dataConTyCon con1 == dataConTyCon con2 )
compare (dataConTag con1) (dataConTag con2)
- compare (DataAlt _) _ = LT
- compare _ (DataAlt _) = GT
+ compare (DataAlt _) _ = GT
+ compare _ (DataAlt _) = LT
compare (LitAlt l1) (LitAlt l2) = compare l1 l2
- compare (LitAlt _) DEFAULT = LT
+ compare (LitAlt _) DEFAULT = GT
compare DEFAULT DEFAULT = EQ
- compare DEFAULT _ = GT
+ compare DEFAULT _ = LT
-- | Binding, used for top level bindings in a module and local bindings in a @let@.