<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The reason I know of why mapM wasn't just made to be an alias for traverse (assuming that's what you mean) was that it was thought that particular definitions of mapM could be more efficient than traverse. For instance:<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">    mapM :: Monad m => (a -> m b) -> [a] -> m [b]<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">    mapM f = go []<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">      where<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">      go ys [] = return (reverse ys)<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">      go ys (x:xs) = f x >>= \y -> go (y:ys) xs<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">This doesn't use stack for m = IO, for instance.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">However, it has since been pointed out (to me and Ed, at least), that this matters much less now. Stack overflows are now off by default, and if you measure the overall time and memory usage, traverse compares favorably to this custom mapM. So, as long as stack isn't an artificially scarce resource, there's no reason to keep them distinct. We didn't know this until after 7.10, though.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">If you're just asking why the definition of 'mapM' for lists isn't 'traverse' with a more specific type, I don't know the answer to that.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">-- Dan<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 11, 2015 at 3:15 PM, Simon Marlow <span dir="ltr"><<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<br>
<br>
Why is this?  Fusion?<br>
<br>
Unfortunately since I want mapM = traverse (for Haxl) I'll need to continue to redefine it in our custom Prelude.<br>
<br>
Cheers,<br>
Simon<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div><br></div>