Where is monadic fold right?

Hi,

Data.Foldable contains foldM which does monadic fold left. Haskell foldable package has functions for both ways.

Is the conventional workaround to do input reverse and use foldM?
For a random access array it is not the most efficient way.

1 Like

I think foldrM is much more useful in a lazy language than a strict one. But no, if I needed a right fold to incorporate monadic effects, I would just use foldr: foldrM f z = foldr (\x y -> f x =<< y) (pure z)

3 Likes