| ... |
... |
@@ -75,7 +75,7 @@ import GHC.Generics (Generic, Generically(..)) |
|
75
|
75
|
import Numeric (fromRat)
|
|
76
|
76
|
import Data.Ratio
|
|
77
|
77
|
import Data.List( find )
|
|
78
|
|
-import qualified Data.Map as FM
|
|
|
78
|
+import qualified Data.Set as Set
|
|
79
|
79
|
import GHC.Real (Ratio(..))
|
|
80
|
80
|
import qualified Data.Semigroup as S
|
|
81
|
81
|
|
| ... |
... |
@@ -388,7 +388,7 @@ data PmLitValue |
|
388
|
388
|
| PmLitOverString FastString
|
|
389
|
389
|
|
|
390
|
390
|
-- | Syntactic equality.
|
|
391
|
|
--- We want (Ord PmLit) so that we can use (Map PmLit x) in `PmAltConSet`
|
|
|
391
|
+-- We want (Ord PmLit) so that we can use (Set PmLit) in `PmAltConSet`
|
|
392
|
392
|
instance Eq PmLit where
|
|
393
|
393
|
a == b = (a `compare` b) == EQ
|
|
394
|
394
|
instance Ord PmLit where
|
| ... |
... |
@@ -510,34 +510,34 @@ data PmAltCon = PmAltConLike ConLike |
|
510
|
510
|
| PmAltLit PmLit
|
|
511
|
511
|
|
|
512
|
512
|
data PmAltConSet = PACS !(UniqDSet ConLike)
|
|
513
|
|
- !(FM.Map PmLit PmLit)
|
|
514
|
|
--- We use a (FM.Map PmLit PmLit) here, at the cost of requiring an Ord
|
|
|
513
|
+ !(Set.Set PmLit)
|
|
|
514
|
+-- We use a (Data.Set.Set PmLit) here, at the cost of requiring an Ord
|
|
515
|
515
|
-- instance for PmLit, because in extreme cases the set of PmLits can be
|
|
516
|
516
|
-- very large. See #26514.
|
|
517
|
517
|
|
|
518
|
518
|
emptyPmAltConSet :: PmAltConSet
|
|
519
|
|
-emptyPmAltConSet = PACS emptyUniqDSet FM.empty
|
|
|
519
|
+emptyPmAltConSet = PACS emptyUniqDSet Set.empty
|
|
520
|
520
|
|
|
521
|
521
|
isEmptyPmAltConSet :: PmAltConSet -> Bool
|
|
522
|
522
|
isEmptyPmAltConSet (PACS cls lits)
|
|
523
|
|
- = isEmptyUniqDSet cls && FM.null lits
|
|
|
523
|
+ = isEmptyUniqDSet cls && Set.null lits
|
|
524
|
524
|
|
|
525
|
525
|
-- | Whether there is a 'PmAltCon' in the 'PmAltConSet' that compares 'Equal' to
|
|
526
|
526
|
-- the given 'PmAltCon' according to 'eqPmAltCon'.
|
|
527
|
527
|
elemPmAltConSet :: PmAltCon -> PmAltConSet -> Bool
|
|
528
|
528
|
elemPmAltConSet (PmAltConLike cl) (PACS cls _ ) = elementOfUniqDSet cl cls
|
|
529
|
|
-elemPmAltConSet (PmAltLit lit) (PACS _ lits) = isJust (FM.lookup lit lits)
|
|
|
529
|
+elemPmAltConSet (PmAltLit lit) (PACS _ lits) = Set.member lit lits
|
|
530
|
530
|
|
|
531
|
531
|
extendPmAltConSet :: PmAltConSet -> PmAltCon -> PmAltConSet
|
|
532
|
532
|
extendPmAltConSet (PACS cls lits) (PmAltConLike cl)
|
|
533
|
533
|
= PACS (addOneToUniqDSet cls cl) lits
|
|
534
|
534
|
extendPmAltConSet (PACS cls lits) (PmAltLit lit)
|
|
535
|
|
- = PACS cls (FM.insert lit lit lits)
|
|
|
535
|
+ = PACS cls (Set.insert lit lits)
|
|
536
|
536
|
|
|
537
|
537
|
pmAltConSetElems :: PmAltConSet -> [PmAltCon]
|
|
538
|
538
|
pmAltConSetElems (PACS cls lits)
|
|
539
|
539
|
= map PmAltConLike (uniqDSetToList cls) ++
|
|
540
|
|
- FM.foldr ((:) . PmAltLit) [] lits
|
|
|
540
|
+ map PmAltLit (Set.toList lits)
|
|
541
|
541
|
|
|
542
|
542
|
instance Outputable PmAltConSet where
|
|
543
|
543
|
ppr = ppr . pmAltConSetElems
|