Proposal: make minimumBy/maximumBy go through foldl', not foldr1

David Feuer david.feuer at gmail.com
Thu Oct 29 18:15:07 UTC 2015


I think it would be very nice to offer a few folds tailored to specific
strictness patterns. I'm not sure of the best interface, however.
On Oct 29, 2015 2:07 PM, "Joachim Breitner" <mail at joachim-breitner.de>
wrote:

> Hi,
>
> Am Donnerstag, den 29.10.2015, 17:34 +0200 schrieb Roman Cheplyaka:
> > I just realized (thanks to this reddit thread[1]) that minimumBy is now
> > implemented through foldr1. Previously (before FTP), minimumBy from
> Data.List
> > used foldl1, while minimumBy from Data.Foldable used foldr1.
> >
> > I think that the way these were merged was a mistake.
>
> this has also been raised by Neil at
> https://ghc.haskell.org/trac/ghc/ticket/10830
>
> Also note https://ghc.haskell.org/trac/ghc/ticket/3416 where it is
> stated that the report demands minimum (and hence minimumBy) to be
> lazy.
>
> Ignoring that argument, and that of not changing libraries light-
> harted, I do think that foldl1' would be the better choice here; users
> who rely on laziness here are likely in the minority and it would be
> reasonable to expect them to manually use foldl1 or foldr1.
>
> BTW, why is there no fold' method in Foldable that leaves the
> associativity (left, right, or mixed in case of a tree) to the Foldable
> instance?
>
>
> Greetings,
> Joachim
>
> --
> Joachim “nomeata” Breitner
>   mail at joachim-breitner.dehttp://www.joachim-breitner.de/
>   Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0xF0FBF51F
>   Debian Developer: nomeata at debian.org
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20151029/854f3b63/attachment.html>


More information about the Libraries mailing list