for is flip traverse.
forM is flip mapM.
And so on with for_, etc.
What about foldMap? It's lonely.
flip foldMap = ?
for is flip traverse.
forM is flip mapM.
And so on with for_, etc.
What about foldMap? It's lonely.
flip foldMap = ?
It would be silly if every 2-argument function had a flipped counterpart. The reason the
forvariants are worthwhile is mainly that they play so nicely together withdonotation, in a way that closely remembers e.g. Python loops.For
foldMapyou could still benefit from a syntax-heralding$+lambda on the RHS, however you wouldn't be in a monad (at least not one used as such), wouldn't usedonotation, and probably would need some parentheses anyway. So there's not much advantage to be had over the regularfoldMapwith a parenthesized function in the middle.