mapM /= traverse?

Simon Marlow marlowsd at gmail.com
Thu May 28 13:31:37 UTC 2015


Yes, we also need mapM_ = traverse_.

Simon

On 26/05/2015 21:59, Dan Doel wrote:
> 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 gmail.com
> <mailto:marlowsd at gmail.com>> 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 haskell.org <mailto:Libraries at haskell.org>
>     http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>


More information about the Libraries mailing list