Proposal: Add a strictly accumulating scanl' to Data.List

David Feuer david.feuer at gmail.com
Mon Oct 27 23:04:53 UTC 2014


There's been no response to this so far, and I'd like to get it for 7.10.1.
Any opinions?
Joachim Breitner wrote, in
https://ghc.haskell.org/trac/ghc/ticket/9345#comment:6, a strictly
accumulating version of scanl, to be named scanl'. I was initially
concerned about its safety for fusion, but am now convinced of its
correctness and believe it should be added to Data.List.

scanl' :: (b -> a -> b) -> b -> [a] -> [b]
scanl' f a bs = build $ \c n ->
  a `seq` a `c`
  foldr (\b g x -> (let b' = f x b in b' `seq` (b' `c` g b')))
         (\b -> b `seq` n)
         bs
         a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141027/a36a2bba/attachment.html>


More information about the Libraries mailing list