Proposal #3999: Improved folds for Data.Map and Data.IntMap

Roman Leshchinskiy rl at cse.unsw.edu.au
Fri Apr 23 06:00:30 EDT 2010


On 23/04/2010, at 19:45, Heinrich Apfelmus wrote:

> Roman Leshchinskiy wrote:
>> Hmm, I'd love to see some real-world uses of foldl. I have no idea
>> what to optimise it for in vector. Unfortunately, the link above
>> doesn't give any examples.
> 
> Here a use of foldl from the Haskell98 Prelude:
> 
>    reverse :: [a] -> [a]
>    reverse = foldl (flip (:)) []
> 
> Basically, foldl is useful if the accumulating parameter uses equal or
> more space if evaluated to normal form than the input list.

What would change if this used foldl' instead?

Roman




More information about the Libraries mailing list