<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Okay. I talked with some folks, and I now understand why this matters for you.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I can't think of a fusion reason for the custom definition. traverse is a foldr same as the particular mapM. I think it's just an oversight.<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Since the type doesn't even change, we should be able to fix this in 7.10.2, no?<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 12, 2015 at 3:58 AM, 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"><span class="">On 11/05/2015 22:41, Dan Doel wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The reason I know of why mapM wasn't just made to be an alias for<br>
traverse (assuming that's what you mean) was that it was thought that<br>
particular definitions of mapM could be more efficient than traverse.<br>
For instance:<br>
<br>
mapM :: Monad m => (a -> m b) -> [a] -> m [b]<br>
mapM f = go []<br>
where<br>
go ys [] = return (reverse ys)<br>
go ys (x:xs) = f x >>= \y -> go (y:ys) xs<br>
<br>
This doesn't use stack for m = IO, for instance.<br>
<br>
However, it has since been pointed out (to me and Ed, at least), that<br>
this matters much less now. Stack overflows are now off by default, and<br>
if you measure the overall time and memory usage, traverse compares<br>
favorably to this custom mapM. So, as long as stack isn't an<br>
artificially scarce resource, there's no reason to keep them distinct.<br>
We didn't know this until after 7.10, though.<br>
<br>
If you're just asking why the definition of 'mapM' for lists isn't<br>
'traverse' with a more specific type, I don't know the answer to that.<br>
</blockquote>
<br></span>
Yes, I'm not really concerned that mapM is a method of Traversable rather than just being an alias for traverse, but I'm wondering why we define it in the list instance rather than using the default.<br>
<br>
Cheers,<br>
Simon<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
-- Dan<br>
<br>
<br>
On Mon, May 11, 2015 at 3:15 PM, Simon Marlow <<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a><br></span><span class="">
<mailto:<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a>>> wrote:<br>
<br>
I was hoping that in GHC 7.10 we would make mapM = traverse for<br>
lists, but it appears this isn't the case: the Traversable instance<br>
for lists overrides mapM to be the manually-defined version in terms<br>
of foldr.<br>
<br>
Why is this? Fusion?<br>
<br>
Unfortunately since I want mapM = traverse (for Haxl) I'll need to<br>
continue to redefine it in our custom Prelude.<br>
<br>
Cheers,<br>
Simon<br>
_______________________________________________<br>
Libraries mailing list<br></span>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a> <mailto:<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>
<br>
<br>
</blockquote>
</blockquote></div><br></div>