diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs index 050f691b23d15d451b729b82329e495fb3ba588d..d85a8740042c6e428c00ddc29f3163ca5dbf3187 100644 --- a/Control/DeepSeq.hs +++ b/Control/DeepSeq.hs @@ -558,10 +558,8 @@ instance NFData a => NFData [a] where rnf = rnf1 -- | @since 1.4.3.0 instance NFData1 [] where - liftRnf r = go - where - go [] = () - go (x : xs) = r x `seq` go xs + liftRnf f = foldr (\x r -> f x `seq` r) () + {-# INLINABLE liftRnf #-} -- | @since 1.4.0.0 instance NFData a => NFData (ZipList a) where rnf = rnf1 diff --git a/changelog.md b/changelog.md index dea799325b8069687ad14b4412c9333e7c951f0c..469fcdc9f3eb0620403043a364056085030ee83b 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,8 @@ ([#95])(https://github.com/haskell/deepseq/pull/95) * Drop support for GHC < 8.6 ([#94](https://github.com/haskell/deepseq/pull/94)) + * List fusion in `instance NFData [a]` reduces allocations + ([#99](https://github.com/haskell/deepseq/pull/99)) ## 1.4.8.1