diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs index 050f691..d85a874 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 dea7993..469fcdc 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