Proposal: strictify foldl'

Niklas Hambüchen mail at nh2.me
Mon Nov 3 17:11:30 UTC 2014


On 03/11/14 17:59, Henning Thielemann wrote:
> I would prefer a strict foldl provided by the
> deepseq package and deprecate foldl' in favor of deepseq:foldl. This new
> foldl could immediately implement the unconditional strictness for the
> initial accumulator value.

This has the problem though that `deepseq` will traverse the entire
structure, and while seq traversals are quite fast, if done n times it
will still take n*n time (this is the classic "why don't deepseq
everywhere" problem, I've stumbled over it again recently).

What I mean to say is: Using `deepseq` in `foldl'` might forbid you to
write some recursive code, e.g. in the cases where you call an outer
foldl' on something whose substructure you used foldl', like when you
use foldl' to fold up a tree from the leaves up.


More information about the Libraries mailing list