Provide an optimized replicateM_ implementation #11795
authorMichael Snoyman <michael@snoyman.com>
Sun, 10 Apr 2016 16:52:47 +0000 (18:52 +0200)
committerBen Gamari <ben@smart-cactus.org>
Sun, 10 Apr 2016 18:09:03 +0000 (20:09 +0200)
commitc4a7520ef3a0b5e0e33d66ae1d628af93e0d7590
treeb01271896c6bd4c0edb966efa1cfd7a118b0f5e4
parent485608d341d5e932fb2f69e3e2bce51a5b34b1b8
Provide an optimized replicateM_ implementation #11795

In my testing, the worker/wrapper transformation applied here
significantly decreases the number of allocations performed when using
replicateM_. Additionally, this version of the function behaves
correctly for negative numbers (namely, it will behave the same as
replicateM_ 0, which is what previous versions of base have done).

Reviewers: bgamari, simonpj, hvr, austin

Reviewed By: bgamari, simonpj, austin

Subscribers: nomeata, simonpj, mpickering, thomie

Differential Revision: https://phabricator.haskell.org/D2086

GHC Trac Issues: #11795
libraries/base/Control/Monad.hs