
#10168: generalize filterM, mapAndUnzipM, zipWithM, zipWithM_, replicateM, replicateM_ -------------------------------------+------------------------------------- Reporter: strake888 | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Core Libraries | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1324 Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Replying to [comment:14 ekmett]:
@strake888:
The notion I think dfeuer was trying to get at there was that `replicateM` can do 'peasant multiplication' like `(^)` does to get away with O(log n) distinct calls to `(<*>)`.
Don't give me so much credit; I was just thinking about eliminating the need for list fusion rules to fire to prevent GHC from building an intermediate list. The peasant multiplication idea is quite an interesting one. It would sometimes be good, and I don't think it could ever be terrible, but it certainly could be ''worse'' in some cases. I'd probably prefer separate combinators for fast exponentiation of `Monoid`s and `Applicative`s. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10168#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler