summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-10-22 17:43:52 -0400
committerBen Gamari <ben@smart-cactus.org>2021-10-22 17:43:52 -0400
commit6902d7eb7f8a2f77a7c825ea15c53e5f7bacbe4d (patch)
treece0615c05f0c55ad9278dad7c96e314ea099fc55
parent2e42b31a705e4b523c2421ab8b12c7b62e16d633 (diff)
downloadhaskell-wip/T19703b.tar.gz
Bag optimisationswip/T19703b
-rw-r--r--compiler/GHC/Data/Bag.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/GHC/Data/Bag.hs b/compiler/GHC/Data/Bag.hs
index 97790e15da..0f4263268b 100644
--- a/compiler/GHC/Data/Bag.hs
+++ b/compiler/GHC/Data/Bag.hs
@@ -337,6 +337,10 @@ instance Foldable.Foldable Bag where
go z (ListBag xs) = foldl' k z xs
{-# INLINEABLE foldl' #-}
+ length = lengthBag
+ null = isEmptyBag
+ x `elem` bag = anyBag (==x) bag
+
instance Traversable Bag where
traverse _ EmptyBag = pure EmptyBag
traverse f (UnitBag x) = UnitBag <$> f x