Commit e14945ce authored by Andreas Klebinger's avatar Andreas Klebinger Committed by Ben Gamari

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:
parent 3bed4aa7
......@@ -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 _ = GT
compare DEFAULT _ = LT
-- | Binding, used for top level bindings in a module and local bindings in a @let@.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment