Proposal: add foldMapWithIndex to Data.Sequence

David Feuer david.feuer at gmail.com
Fri May 20 17:20:41 UTC 2016


foldMapWithIndex :: Monoid m
     => (Int -> a -> m) -> Seq a -> m

This would match both Data.Map.foldMapWithKey and
Control.Lens.Indexed.ifoldMap, filling out the indexed fold menagerie.

Annoyingly, the straightforward implementation I've come up with is rather
slow when used with Endo to implement either foldlWithIndex or
foldrWithIndex. I suspect the polymorphic recursion inherent in these
sequences is blinding GHC's optimizer. Oh well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160520/dbf6b77f/attachment.html>


More information about the Libraries mailing list