Open konsumlamm opened 4 years ago
Yes. For min-queues, we want foldlAsc'
and foldrDesc'
. For max-queues, we want foldlDesc'
and foldrAsc'
. For all queues, we want foldlU'
and possibly foldrU'
. (Of course, we'll also want the WithKey
versions.)
The current documentation for the unordered folds makes it pretty silly to have both left and right-handed versions. Obeying the documentation, we could define foldlWithKeyU f = foldrWithKeyU (\k a b -> f b k a)
. We really should either:
foldrU
and foldlU'
only, orreverse . foldrU (:) [] = foldlU (flip (:)) []
. I think I prefer this option.foldlU'
was added in #59, so for unordered folds, this now has been addressed.
There are currently no strict fold operations (except for the Foldable instances ofc) in this package. Would it be worthwhile to add strict variants of the different folds that are provided (like
foldrU
,foldlU
)? Or is there any particular reason to not include them?Regarding the implementation, they could just be implemented like the default definitions of
foldr'
andfoldl'
.