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

(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

(+1) on foldl', (-1) on foldr' for the reasons outlined in the other mailing list. On 02/24/2015 02:42 PM, Bob Ippolito 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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Same here (+1 foldl', -1 foldr')
On 24 February 2015 at 21:44, Chris Allen
(+1) on foldl', (-1) on foldr' for the reasons outlined in the other mailing list.
On 02/24/2015 02:42 PM, Bob Ippolito 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 listLibraries@haskell.orghttp://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- *Λ\ois* http://twitter.com/aloiscochard http://github.com/aloiscochard

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
https://mail.haskell.org/pipermail/libraries/2013-July/020455.html 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.
-Edward
On Tue, Feb 24, 2015 at 3:42 PM, Bob Ippolito
(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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

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?
That is one way but I think another way is to make foldl strict: http://www.well-typed.com/blog/90/ I'm tired of explaining the difference of foldl and foldl' to beginners. :-) --Kazu

No, that is not a way now that we have FTP.
On Wed, Feb 25, 2015 at 7:31 PM, Kazu Yamamoto
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?
That is one way but I think another way is to make foldl strict:
http://www.well-typed.com/blog/90/
I'm tired of explaining the difference of foldl and foldl' to beginners. :-)
--Kazu _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Why not? David Feuer wrote:
No, that is not a way now that we have FTP.
On Wed, Feb 25, 2015 at 7:31 PM, Kazu Yamamoto
wrote: 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?
That is one way but I think another way is to make foldl strict:
http://www.well-typed.com/blog/90/
I'm tired of explaining the difference of foldl and foldl' to beginners. :-)
--Kazu

FTP sets up the expectation that foldl has a specific relationship to
foldMap. I suppose you could go against that, and also break any code
relying on the current foldl semantics, but I'd personally be very much
opposed to that.
On Mar 1, 2015 5:13 PM, "Ben Franksen"
Why not?
David Feuer wrote:
No, that is not a way now that we have FTP.
On Wed, Feb 25, 2015 at 7:31 PM, Kazu Yamamoto
wrote: 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?
That is one way but I think another way is to make foldl strict:
http://www.well-typed.com/blog/90/
I'm tired of explaining the difference of foldl and foldl' to beginners. :-)
--Kazu
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

David Feuer wrote:
FTP sets up the expectation that foldl has a specific relationship to foldMap.
How does foldl have a more specific relationship with foldMap than foldl'? Both are currently methods of class Foldable, BTW.
I suppose you could go against that,
I have not yet formed an opinion. I just want to understand your response which remains cryptic to me.
and also break any code relying on the current foldl semantics, but I'd personally be very much opposed to that.
Fair enough, but a different matter. Cheers Ben
On Mar 1, 2015 5:13 PM, "Ben Franksen"
wrote: Why not?
David Feuer wrote:
No, that is not a way now that we have FTP.
On Wed, Feb 25, 2015 at 7:31 PM, Kazu Yamamoto
wrote: 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?
That is one way but I think another way is to make foldl strict:
http://www.well-typed.com/blog/90/
I'm tired of explaining the difference of foldl and foldl' to beginners. :-)
--Kazu

On Sat, Mar 7, 2015 at 6:08 PM, Ben Franksen
David Feuer wrote:
FTP sets up the expectation that foldl has a specific relationship to foldMap.
How does foldl have a more specific relationship with foldMap than foldl'? Both are currently methods of class Foldable, BTW.
Yes, and each is expected to have a specific relationship to foldMap. Changing the foldl for lists breaks that. David
participants (8)
-
Alois Cochard
-
Ben Franksen
-
Bob Ippolito
-
Chris Allen
-
David Feuer
-
Edward Kmett
-
John Wiegley
-
Kazu Yamamoto