I find myself writing something like this a lot:
let
acc = ...
in
foldl' acc mempty xs
for the simple reason that the accumulating function acc
usually doesn’t fit in that same line with foldl'
.
What I am missing is, what for
and for_
do to traverse
and traverse_
and <&>
to fmap
: a way to write
myVersionOffold mempty xs $ \acc x ->
...
Is there some sort of general consensus on how to write those accumulator functions for folds? In my code, they practically never deserve a name, as they are really only used once in the fold.