Should foldl' be added to the post-"Plan FTP" Prelude

Edward Kmett ekmett at
Wed Feb 25 21:08:07 UTC 2015

We tried to minimize the extra symbols we took from the Prelude in 7.10,
while ensuring you could write most instances.

We left off exporting fold, foldr', foldl' and toList from the Prelude
because they were names we didn't strictly have to take.

foldMap was necessary as a minimal definition of the class, and Monoid was
needed to deal not only with foldMap, but also to avoid orphaning the
existing Applicative ((,) m) writer instance, and implement the Monad for
((,) m) which had previously passed libraries@ review on multiple
occasions, most recently in 2013
<> but
had been heretofore blocked by the internal structure of base.

I'm happy to have a conversation about adding foldl' to the Prelude, it is
arguably the right default for a huge class of operations on different
containers. I'd also be happy to have a conversation about just exporting
all of the API of Foldable. We originally planned on punting that off to
7.12 as exporting _any_ additional names from the Prelude was already a big
step for us to ask the community to take, and we're still trying to get a
sense of the community's appetite for such changes.

As for exporting foldl' while not exporting foldr' note that that is a
rather large pessimization for containers like Vector, which can admit time
and space efficient versions of both foldl' and foldr'. The assumption that
foldr' is always bad is very list-centric.


On Tue, Feb 24, 2015 at 3:42 PM, Bob Ippolito <bob at> wrote:

> (Cross-posted from haskell-cafe as suggested by Carter Schonwald)
> I would love to have foldl' as part of the Prelude. I use it quite
> frequently and it seems like a beginner trap to have foldl but not foldl'
> (which is almost always the better choice). I see that foldMap has been
> added (in addition to all of Monoid and Traversable), why was foldl' left
> out?
> It might be good measure to add foldr' as well, although I use that much
> less frequently.
> -bob
> _______________________________________________
> Libraries mailing list
> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list