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

GHC ghc-devs at haskell.org
Mon Aug 4 07:16:06 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:              |          Version:  7.8.3
  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 nomeata):

 >  Yes, it actually cycles the argument and then maps over the
 result—horrible in every way.

 But this is well-known: You usually cannot “modify” cyclic data structures
 without breaking them.

 Of course its cool that with the above definition of `cycle` + fusion, we
 can suddenly `map` over a cyclic structure without breaking it, but maybe
 that’s a tad too much magic? Especially as people probably don’t have a
 good feeling for when this happens and when not? OTOH, I don’t think it
 hurts either, and nice surprises are – well – nice.

 Did you investigate why `foldr (+) 0 $ take 30000000 $ map (* 13) $ cycle
 [1,8,4,0,(5::Int)]` allocates more?

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


More information about the ghc-tickets mailing list