Proposal: Add concatMapM function (#2042)

Yitzchak Gale gale at sefer.org
Mon Jan 14 21:54:52 EST 2008


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
>    join :: Traversable t => t (t c) -> t c
>    join = runIdentity . concatMapM return

Since return for the Identity monad is essential the identity,
shouldn't we always have

mapM return = return

for that monad? In that case, your formula is indeed
always true:

runIdentity . concatMapM return
= runIdentity . liftM join . mapM return
= runIdentity . liftM join . return
= runIdentity . return . join
= join

Regards,
Yitz


More information about the Libraries mailing list