From 2f050687e75ffe6fbf140cacd15fd916d2997499 Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Wed, 28 Sep 2022 00:15:53 +0100 Subject: Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. --- compiler/GHC/Tc/Gen/Expr.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'compiler/GHC/Tc/Gen') diff --git a/compiler/GHC/Tc/Gen/Expr.hs b/compiler/GHC/Tc/Gen/Expr.hs index c5c5616024..c2a680b3d4 100644 --- a/compiler/GHC/Tc/Gen/Expr.hs +++ b/compiler/GHC/Tc/Gen/Expr.hs @@ -88,7 +88,8 @@ import GHC.Types.Unique.Set ( UniqSet, mkUniqSet, elementOfUniqSet, nonDetEltsUn import Language.Haskell.Syntax.Basic (FieldLabelString(..)) import Data.Function -import Data.List (partition, sortBy, groupBy, intersect) +import Data.List (partition, sortBy, intersect) +import qualified Data.List.NonEmpty as NE import GHC.Data.Bag ( unitBag ) @@ -1699,7 +1700,7 @@ badFieldsUpd rbinds data_cons in -- Fields that don't change the membership status of the set -- are redundant and can be dropped. - map (fst . head) $ groupBy ((==) `on` snd) growingSets + map (fst . NE.head) $ NE.groupWith snd growingSets aMember = assert (not (null members) ) fst (head members) (members, nonMembers) = partition (or . snd) membership -- cgit v1.2.1