Adding partial foldl1' to Foldable?

George Wilson george at
Mon Jan 11 09:07:22 UTC 2021

I am sympathetic to the completeness argument, but I would prefer that
we not add more partial functions to base. Having foldl1 and foldr1 in
Foldable in the first place is something I consider a wart. Hopefully
we can remove them in the future.
Would it make sense to omit foldl1/foldr1/foldl1'/foldr1' entirely
from your explanation? Then it would be future-proofed against such
removal :)


On Mon, 21 Dec 2020 at 08:16, Viktor Dukhovni <ietf-dane at> wrote:
> Given that Foldable currently has:
>     - foldr and foldr'
>     - foldl and foldl'
>     - foldMap and foldMap'
> and also has only:
>     - foldr1
>     - foldl1
> it seems natural to ask whether there it should also have a strict
> variant of at least foldl1, since the non-strict variant has rather
> limited applicability, and users would/should in most cases want/use
> the strict `foldl1'` instead.
> --
>     Viktor.
> P.S.  I just joined the list today, but noticed that coincidentally, there's
> already a recent dicussion of Foldable1, which rather overlaps with this
> question, and perhaps the partial `foldr1` and `foldl1` should be seen
> as deprecated, once a suitable class of non-empty containers provides
> total variants.  But perhaps on the other hand, given that the partial
> functions already exist, perhaps adding the strict companions is
> warranted?
> I am asking because I am writing some expository prose for
> Data.Foldable, to go at the bottom of the document, structurally along
> the lines of what I contributed for Data.Traversable, but with a fairly
> different focus.  The goal is draw careful distinctions between
> strict recursive and lazy corecursive reductions, explaining their
> proper usage and typical implementations.  The "missing" `foldl1'`
> was something I ran into while working on part of the writeup.
> _______________________________________________
> Libraries mailing list
> Libraries at

More information about the Libraries mailing list