[GHC] #9398: Data.List.cycle is not a good producer

GHC ghc-devs at haskell.org
Sun Aug 3 07:39:01 UTC 2014


#9398: Data.List.cycle is not a good producer
-------------------------------------+-------------------------------------
       Reporter:  dfeuer             |                   Owner:
           Type:  bug                |                  Status:  new
       Priority:  normal             |               Milestone:  7.8.4
      Component:  libraries/base     |                 Version:  7.8.3
       Keywords:                     |        Operating System:
   Architecture:  Unknown/Multiple   |  Unknown/Multiple
     Difficulty:  Easy (less than 1  |         Type of failure:  Runtime
  hour)                              |  performance bug
     Blocked By:                     |               Test Case:
Related Tickets:                     |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
 Data.List.cycle is not a good producer. I'm not at all sure this solution
 is the best, but it allocates much less when mapped over and then folded.
 If we could make it a good consumer cheaply that would be nice too, but I
 imagine it's probably mostly applied to short lists, so that is probably
 not a priority.

 {{{#!hs
 {-# INLINE cycle #-}
 cycle :: [a] -> [a]
 cycle [] = error "Prelude.cycle: empty list"
 cycle xs = concat $ repeat xs
 }}}

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


More information about the ghc-tickets mailing list