Strict folds without base case to `Data.Foldable`.

Hello. I notice that in `"base" Data.Foldable` there are strict left and right folds, but no corresponding folds without base case, that is, `foldl1'` and `foldr1'`. Can this omission be ameliorated? The implementation is trivial.

This was discussed in December 2020:
https://mail.haskell.org/pipermail/libraries/2020-December/031010.html
Am Mi., 30. Juni 2021 um 12:49 Uhr schrieb Ignat Insarov
Hello.
I notice that in `"base" Data.Foldable` there are strict left and right folds, but no corresponding folds without base case, that is, `foldl1'` and `foldr1'`. Can this omission be ameliorated? The implementation is trivial. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Actually, following your link, I cannot find any discussion of the original
question about foldr1' or foldl1'. The discussion goes on about enhancing the
documentation of Data.Foldable. Please let me know if I missed something!
Dominik
Simon Jakobi via Libraries
This was discussed in December 2020: https://mail.haskell.org/pipermail/libraries/2020-December/031010.html
Am Mi., 30. Juni 2021 um 12:49 Uhr schrieb Ignat Insarov
: Hello.
I notice that in `"base" Data.Foldable` there are strict left and right folds, but no corresponding folds without base case, that is, `foldl1'` and `foldr1'`. Can this omission be ameliorated? The implementation is trivial. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Apologies, I should have taken a closer look.
It seems that the only response to this proposal came in January 2021:
https://mail.haskell.org/pipermail/libraries/2021-January/031116.html
I seem to remember some more discussion, probably elsewhere, but I
can't find it right now.
Am Mi., 30. Juni 2021 um 14:30 Uhr schrieb Dominik Schrempf
Actually, following your link, I cannot find any discussion of the original question about foldr1' or foldl1'. The discussion goes on about enhancing the documentation of Data.Foldable. Please let me know if I missed something!
Dominik
Simon Jakobi via Libraries
writes: This was discussed in December 2020: https://mail.haskell.org/pipermail/libraries/2020-December/031010.html
Am Mi., 30. Juni 2021 um 12:49 Uhr schrieb Ignat Insarov
: Hello.
I notice that in `"base" Data.Foldable` there are strict left and right folds, but no corresponding folds without base case, that is, `foldl1'` and `foldr1'`. Can this omission be ameliorated? The implementation is trivial. _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Whichever floats your boats folks. I am a user of Haskell and I require strict folds without base case. Further I dare not meddle.

On Thu, Jul 01, 2021 at 12:01:51AM +0500, Ignat Insarov wrote:
Whichever floats your boats folks. I am a user of Haskell and I require strict folds without base case. Further I dare not meddle.
To what sort of structure(s) are looking to apply a strict foldl1? Since there is no `foldl1'` class method to override, no structures have a specialised definition. Therefore, a "default" definition can be written outside the class: foldl1' :: Foldable t => (a -> a -> a) -> t a -> a foldl1' f = fromMaybe (errorWithoutStackTrace "foldl1': empty structure") . foldl' f' Nothing where f' ma x = Just $! case ma of Nothing -> x Just a -> f a x Which means you can just use this in your own code, it need not first land in the Data.Foldable module for you to make use of it. -- Viktor. P.S. FWIW, apologies if I am misreading the tone of your message, but it does sound "demanding" to me. GHC is a free community project with no large corporation invested in its development, all the contributors want to help users, but this is easier to help users who are considerate of those to would volunteer their time to help.

Since there is no `foldl1'` class method to override, no structures have a specialised definition. Therefore, a "default" definition can be written outside the class …
I know, Viktor. I have already written a definition very similar to yours. I even said in my first message that the implementation is trivial. The question is whether I should accept that patching over deficiencies of `base` is normal.
P.S. FWIW, apologies if I am misreading the tone of your message, but it does sound "demanding" to me. GHC is a free community project …
This is exactly why I am still here. Even though I have seen good and worthy proposals drowned in endless pondering over minutiae. Do I want to help improve the common goods? Yes. Am I happy with how it has been going so far? No.
… with no large corporation invested in its development, all the contributors want to help users, but this is easier to help users who are considerate of those to would volunteer their time to help.
This is not about _«help»_. I am not asking for help. I have technical requirements from a certain library, here `base`. I made the maintainers aware of these requirements. I cannot force the maintainers to improve the library, the maintainers cannot cancel my requirement.
participants (5)
-
Dominik Schrempf
-
Henning Thielemann
-
Ignat Insarov
-
Simon Jakobi
-
Viktor Dukhovni