[Git][ghc/ghc][master] Keep scanl' strict in the head on rewrite

Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 33b546bd by meooow25 at 2025-07-07T20:46:09-04:00 Keep scanl' strict in the head on rewrite `scanl'` forces elements to WHNF when the corresponding `(:)`s are forced. The rewrite rule for `scanl'` missed forcing the first element, which is fixed here with a `seq`. - - - - - 2 changed files: - libraries/base/changelog.md - libraries/ghc-internal/src/GHC/Internal/List.hs Changes: ===================================== libraries/base/changelog.md ===================================== @@ -26,6 +26,7 @@ * Expose constructor and field of `Backtraces` from `Control.Exception.Backtrace`, as per [CLC #199](https://github.com/haskell/core-libraries-committee/issues/199#issuecomment-...) * Fix incorrect results of `integerPowMod` when the base is 0 and the exponent is negative, and `integerRecipMod` when the modulus is zero ([#26017](https://gitlab.haskell.org/ghc/ghc/-/issues/26017)). + * Fix the rewrite rule for `scanl'` not being strict in the first element of the output list ([#26143](https://gitlab.haskell.org/ghc/ghc/-/issues/26143)). ## 4.21.0.0 *December 2024* ===================================== libraries/ghc-internal/src/GHC/Internal/List.hs ===================================== @@ -601,7 +601,7 @@ scanl' = scanlGo' -- See Note [scanl rewrite rules] {-# RULES "scanl'" [~1] forall f a bs . scanl' f a bs = - build (\c n -> a `c` foldr (scanlFB' f c) (flipSeq n) bs a) + build (\c n -> a `seq` (a `c` foldr (scanlFB' f c) (flipSeq n) bs a)) "scanlList'" [1] forall f a bs . foldr (scanlFB' f (:)) (flipSeq []) bs a = tail (scanl' f a bs) #-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33b546bd47606f6ebca08a8138f16426... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/33b546bd47606f6ebca08a8138f16426... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)