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
for
variants are worthwhile is mainly that they play so nicely together withdo
notation, in a way that closely remembers e.g. Python loops.For
foldMap
you 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 usedo
notation, and probably would need some parentheses anyway. So there's not much advantage to be had over the regularfoldMap
with a parenthesized function in the middle.