<div dir="ltr"><div>From the patch fragment at<br><div><br><a href="https://phabricator.haskell.org/D455?id=1311#inline-3123">https://phabricator.haskell.org/D455?id=1311#inline-3123</a><br><br></div>What's the justification for expanding out the definition of mapM from "sequence . map f" into do-notation and duplicated code?<br><br></div><div>Observe how mapM now duplicates code from sequence.<br><br></div><div>The absence of benchmarks is bad enough. What's worse is that the given excuse boils down to "Pity the poor compiler! Let's take over its work instead. Like, just in case, you know."<br></div><div><div><div><div><div class="gmail_extra"><br></div><div class="gmail_extra">This optimization work needs to take place at a higher level, with deep understanding of existing compiler transformations. Otherwise, it's all a code-muddying crapshoot in the dark.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div><div class="gmail_signature">-- Kim-Ee</div></div>
<br><div class="gmail_quote">On Tue, Nov 11, 2014 at 2:22 PM, GHC <span dir="ltr"><<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">#9781: Make list monad operations fuse<br>
-------------------------------------+-------------------------------------<br>
              Reporter:  dfeuer      |            Owner:  dfeuer<br>
</span>                  Type:  task        |           Status:  patch<br>
              Priority:  normal      |        Milestone:  7.10.1<br>
<span class="">             Component:  Core        |          Version:  7.9<br>
  Libraries                          |         Keywords:<br>
            Resolution:              |     Architecture:  Unknown/Multiple<br>
      Operating System:              |       Difficulty:  Unknown<br>
  Unknown/Multiple                   |       Blocked By:<br>
       Type of failure:  Runtime     |  Related Tickets:<br>
  performance bug                    |<br>
</span><span class="">             Test Case:              |<br>
              Blocking:              |<br>
Differential Revisions:  Phab:D455   |<br>
-------------------------------------+-------------------------------------<br>
<br>
</span>Comment (by Herbert Valerio Riedel <hvr@…>):<br>
<br>
 In [changeset:"4923cea56345060faaf77e4c475eac6aa3c77506/ghc"]:<br>
 {{{<br>
 #!CommitTicketReference repository="ghc"<br>
 revision="4923cea56345060faaf77e4c475eac6aa3c77506"<br>
 Define list monad operations using comprehensions<br>
<br>
 Define list monad operations using list comprehensions. Code using monad<br>
 operations with lists did not fuse fully. Writing list code with `do`<br>
 notation or `(>>=)` and `(>>)` operations could allocate more than<br>
 equivalent code using list comprehensions.<br>
<br>
 Define `mapM` directly, instead of using `sequence` and `map`. This<br>
 leads to substantially less allocation in `cryptarithm2`.<br>
<br>
 Addresses #9781<br>
<br>
 Reviewed By: ekmett, nomeata<br>
<br>
 Differential Revision: <a href="https://phabricator.haskell.org/D455" target="_blank">https://phabricator.haskell.org/D455</a><br>
 }}}<br>
<br>
--<br>
Ticket URL: <<a href="http://ghc.haskell.org/trac/ghc/ticket/9781#comment:4" target="_blank">http://ghc.haskell.org/trac/ghc/ticket/9781#comment:4</a>><br>
<div class=""><div class="h5">GHC <<a href="http://www.haskell.org/ghc/" target="_blank">http://www.haskell.org/ghc/</a>><br>
The Glasgow Haskell Compiler<br>
_______________________________________________<br>
ghc-tickets mailing list<br>
<a href="mailto:ghc-tickets@haskell.org">ghc-tickets@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/ghc-tickets" target="_blank">http://www.haskell.org/mailman/listinfo/ghc-tickets</a><br>
</div></div></blockquote></div><br></div></div></div></div></div></div>