Proposal: add fusion RULES for Data.Map.mapMaybe

Hi, Currently mapMaybe does not fuse at all. The attached patch implements necessary rules for fold/build fusion in both sides (the result and the second argument) to happen. When fusion does not happen, the function should behave exactly the same as before. I ran some benchmarks, testing cases where fusion does and does not happen: http://htmlpreview.github.io/?https://github.com/takano-akio/mapmaybe-benchm... The benchmark code is: https://github.com/takano-akio/mapmaybe-benchmarks/blob/master/main.hs Discussion period: 2 weeks. Thank you, Takano Akio

Hi, Am Mittwoch, den 20.11.2013, 16:40 +0900 schrieb Akio Takano:
Currently mapMaybe does not fuse at all. The attached patch implements necessary rules for fold/build fusion in both sides (the result and the second argument) to happen. When fusion does not happen, the function should behave exactly the same as before.
+1. Also, the code seems to be correct (at least quickcheck tells me so). Thanks for the contribution, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • http://www.joachim-breitner.de/ Jabber: nomeata@joachim-breitner.de • GPG-Key: 0x4743206C Debian Developer: nomeata@debian.org

+1
Makes sense to me.
-Edward
On Wed, Nov 20, 2013 at 2:40 AM, Akio Takano
Hi,
Currently mapMaybe does not fuse at all. The attached patch implements necessary rules for fold/build fusion in both sides (the result and the second argument) to happen. When fusion does not happen, the function should behave exactly the same as before.
I ran some benchmarks, testing cases where fusion does and does not happen:
http://htmlpreview.github.io/?https://github.com/takano-akio/mapmaybe-benchm...
The benchmark code is:
https://github.com/takano-akio/mapmaybe-benchmarks/blob/master/main.hs
Discussion period: 2 weeks.
Thank you, Takano Akio
-- You received this message because you are subscribed to the Google Groups "haskell-core-libraries" group. To unsubscribe from this group and stop receiving emails from it, send an email to haskell-core-libraries+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.

The proposal received support from two people, and got no objection, so I
created a ticket for it on the GHC trac.
https://ghc.haskell.org/trac/ghc/ticket/8595
Thank you,
Takano Akio
On Wed, Nov 20, 2013 at 4:40 PM, Akio Takano
Hi,
Currently mapMaybe does not fuse at all. The attached patch implements necessary rules for fold/build fusion in both sides (the result and the second argument) to happen. When fusion does not happen, the function should behave exactly the same as before.
I ran some benchmarks, testing cases where fusion does and does not happen:
http://htmlpreview.github.io/?https://github.com/takano-akio/mapmaybe-benchm...
The benchmark code is:
https://github.com/takano-akio/mapmaybe-benchmarks/blob/master/main.hs
Discussion period: 2 weeks.
Thank you, Takano Akio
participants (3)
-
Akio Takano
-
Edward Kmett
-
Joachim Breitner