
I wrote:
perhaps nowadays the type ought to be: concatMapM :: (Monad m, Traversable t) => (a -> m (t b)) -> t a -> m (t b)
apfelmus wrote:
I don't think that works in such generality since that would imply... that every Traversable would have to be a monad.
Ah, of course. Sorry, I wrote that in the wee hours of the morning. Now I also understand Ross Patterson's answer - that a Monoid structure could also be substituted for the Monad structure, because concat generalizes both to join and to mappend.
Since this is not always the case (really?)
Right. Given a tree of trees, there are many ways to paste them together into a single tree, but all of those ways use the actual tree structure, not just the fact that I can traverse over trees. You can't paste them together - but you can traverse them. So I guess the corresponding concept for traversables is that are composable over monads: mapMapM :: (Traversable t, Traversable t', Monad m) => (b -> m c) -> (a -> m (t b)) -> t' a -> m (t' (t c)) mapMapM f g = (>>= mapM (mapM f)) . mapM g I don't immediately see any composability over applicatives. Am I missing something obvious? Thanks, Yitz