I’d like to make a feature request: Add a version of foldS (maybe even foldP) that adds an accumulator, i.e. allows you to pass some state around.
There seem to be other people missing this feature too:
http://stackoverflow.com/questions/13570354/haskell-repa-how-to-reduce-array-and-return-index
http://stackoverflow.com/questions/13298778/calculate-an-image-histogram-with-repa
From the 2nd thread:
> This is really only a problem because Repa doesn't have what I consider a normal traverse function. Repa's traverse is more of an array construction that happens to provide an indexing function into another array. We want traverse in the form:
>
> newTraverse :: Array r sh e -> a -> (a -> sh -> e -> a) -> a
> but of coarse this is actually just a malformed fold. So lets rename it and reorder the arguments:
>
> foldAllIdxS :: (sh -> a - > e -> a) -> a -> Array r sh e -> a
> which contrasts nicely with the (preexisting) foldAllS operation:
>
> foldAllS :: (a -> a -> a) -> a -> Array r sh a -> a
> Notice how our new fold has two critical characteristics. The result type is not required to match the element type, so we could start with a tuple of Histograms. Second, our version of fold passes the index, which allows you to select which histogram in the tuple to update (if any).
Jonas