diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-10-18 13:40:23 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-10-20 14:07:49 -0400 |
commit | 05b8a21884fb3b283acb7d148afc875a95f7752c (patch) | |
tree | d41b6dcdb9ef529593ab45d3c1e8d82c5db847d0 /compiler/GHC/Data | |
parent | ef92d88928651fa21b3b23d054f8a97d7b6104cd (diff) | |
download | haskell-05b8a21884fb3b283acb7d148afc875a95f7752c.tar.gz |
Make fields of GlobalRdrElt strict
In order to do this I thought it was prudent to change the list type to
a bag type to avoid doing a lot of premature work in plusGRE because of
++.
Fixes #19201
Diffstat (limited to 'compiler/GHC/Data')
-rw-r--r-- | compiler/GHC/Data/Bag.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/GHC/Data/Bag.hs b/compiler/GHC/Data/Bag.hs index e0e43d5ad1..4171d7b03e 100644 --- a/compiler/GHC/Data/Bag.hs +++ b/compiler/GHC/Data/Bag.hs @@ -17,7 +17,7 @@ module GHC.Data.Bag ( filterBag, partitionBag, partitionBagWith, concatBag, catBagMaybes, foldBag, isEmptyBag, isSingletonBag, consBag, snocBag, anyBag, allBag, - listToBag, nonEmptyToBag, bagToList, mapAccumBagL, + listToBag, nonEmptyToBag, bagToList, headMaybe, mapAccumBagL, concatMapBag, concatMapBagPair, mapMaybeBag, mapBagM, mapBagM_, flatMapBagM, flatMapBagPairM, @@ -33,7 +33,7 @@ import GHC.Utils.Misc import GHC.Utils.Monad import Control.Monad import Data.Data -import Data.Maybe( mapMaybe ) +import Data.Maybe( mapMaybe, listToMaybe ) import Data.List ( partition, mapAccumL ) import Data.List.NonEmpty ( NonEmpty(..) ) import qualified Data.Foldable as Foldable @@ -308,6 +308,12 @@ nonEmptyToBag (x :| xs) = ListBag (x : xs) bagToList :: Bag a -> [a] bagToList b = foldr (:) [] b +headMaybe :: Bag a -> Maybe a +headMaybe EmptyBag = Nothing +headMaybe (UnitBag v) = Just v +headMaybe (TwoBags b1 _) = headMaybe b1 +headMaybe (ListBag l) = listToMaybe l + instance (Outputable a) => Outputable (Bag a) where ppr bag = braces (pprWithCommas ppr (bagToList bag)) |