purescript-foldable-traversable
purescript-foldable-traversable copied to clipboard
foldrM
Is there any reason why there is foldlM (foldM) and there is no foldrM? I was confused because I didn't hit when I searched for this in pursuit.
foldrM :: forall a m b f. Foldable f => Monad m => (a -> b -> m b) -> b -> f a -> m b
foldrM f z0 xs = foldl c pure xs z0
where c k x z = f x z >>= k
It was probably an oversight?
I think because nobody has asked for it before, and I think not adding things to the core libraries if there isn't a clear demand for them is generally a good strategy. (That's not to say that we can't add it now, though).
There's some discussion in https://github.com/purescript/purescript-foldable-traversable/pull/111.