summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHécate <hecate+gitlab@glitchbra.in>2020-12-23 14:56:42 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-02 07:35:54 -0500
commitbc383cb060adc97cb38e41acfb42d63a449f4b64 (patch)
tree9e0292f58e3847a63c0e017db95deb65d64ec52e
parentd9788fd27da499bd8ca8c38980728088b961a5bc (diff)
downloadhaskell-bc383cb060adc97cb38e41acfb42d63a449f4b64.tar.gz
Upstream the strictness optimisation for GHC.List.{sum,product}
-rw-r--r--libraries/base/GHC/List.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/libraries/base/GHC/List.hs b/libraries/base/GHC/List.hs
index 732ba13848..4146b68319 100644
--- a/libraries/base/GHC/List.hs
+++ b/libraries/base/GHC/List.hs
@@ -340,7 +340,7 @@ foldl1' _ [] = errorEmptyList "foldl1'"
-- * Hangs forever *
sum :: (Num a) => [a] -> a
{-# INLINE sum #-}
-sum = foldl (+) 0
+sum = foldl' (+) 0
-- | The 'product' function computes the product of a finite list of numbers.
--
@@ -356,7 +356,7 @@ sum = foldl (+) 0
-- * Hangs forever *
product :: (Num a) => [a] -> a
{-# INLINE product #-}
-product = foldl (*) 1
+product = foldl' (*) 1
-- | \(\mathcal{O}(n)\). 'scanl' is similar to 'foldl', but returns a list of
-- successive reduced values from the left: