From bc383cb060adc97cb38e41acfb42d63a449f4b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9cate?= Date: Wed, 23 Dec 2020 14:56:42 +0100 Subject: Upstream the strictness optimisation for GHC.List.{sum,product} --- libraries/base/GHC/List.hs | 4 ++-- 1 file 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: -- cgit v1.2.1