[GHC] #9434: GHC.List.reverse does not fuse

GHC ghc-devs at haskell.org
Sun Aug 31 09:31:42 UTC 2014


#9434: GHC.List.reverse does not fuse
-------------------------------------+-------------------------------------
              Reporter:  dfeuer      |            Owner:
                  Type:  bug         |           Status:  patch
              Priority:  normal      |        Milestone:
             Component:              |          Version:  7.9
  libraries/base                     |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Easy (less than 1
  Unknown/Multiple                   |  hour)
       Type of failure:  Runtime     |       Blocked By:
  performance bug                    |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 Replying to [comment:9 dfeuer]:
 > Replying to [comment:8 nomeata]:
 > > AT least for `filter p . reverse`, couldn’t you rewrite it to `reverse
 . filter p` if that is for whatever reason better? Seems to be a nice
 small optimization (though, like many of them, probably of little
 practical relevance.)
 >
 > Unfortunately, that changes semantics. `filter (==1) (reverse
 [undefined,1,2]) = 1:undefined` but `reverse (filter (==1)
 [undefined,1,2]) = undefined`

 And to go along with that, as dolio mentioned to me, the performance may
 be worse if only part of the list is used and the filter predicate is
 expensive.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9434#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list