mapM /= traverse?

Dan Doel dan.doel at
Tue May 26 18:59:45 UTC 2015

I'm going to submit a ticket for this. However, I have a related question:

Do you care about mapM_? Right now it's defined as:

    mapM_ f = foldr ((>>) . f) (return ())

whereas it could be:

    mapM_ = traverse_

Does this not affect you in the same way (because (>>) allows the same
optimization as Applicative)? Or does this also need to be addressed?

-- Dan

On Mon, May 11, 2015 at 3:15 PM, Simon Marlow <marlowsd at> wrote:

> I was hoping that in GHC 7.10 we would make mapM = traverse for lists, but
> it appears this isn't the case: the Traversable instance for lists
> overrides mapM to be the manually-defined version in terms of foldr.
> Why is this?  Fusion?
> Unfortunately since I want mapM = traverse (for Haxl) I'll need to
> continue to redefine it in our custom Prelude.
> Cheers,
> Simon
> _______________________________________________
> Libraries mailing list
> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list