#4978: Continuation passing style loop doesn't compile into a loop
---------------------------------+------------------------------------------
    Reporter:  tibbe             |        Owner:              
        Type:  bug               |       Status:  new         
    Priority:  normal            |    Milestone:              
   Component:  Compiler          |      Version:  7.0.1       
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by tibbe):

 Actually, I can unbox `Buffer` by redefining `empty` like so:

 {{{
 empty :: Builder
 empty = Builder (\ k b -> b `seq` k b)
 {-# INLINE empty #-}
 }}}

 That gives me a "perfect" loop in the previous example. However,
 redefining `empty` in the real `Data.Binary.Builder` module doesn't work.
 The extra `seq` gets in the way of the arity analysis. I've attached
 `Repro3.hs`, which is very similar to the code I posted previously except
 that now includes code to allocate a new buffer when needed (that part was
 stubbed out in the above example).

 If I don't add the `seq` to `empty` the arity analysis works, but `Buffer`
 gets passed around boxed. If I add the `seq` I get an unboxed `Buffer`,
 but the arity analysis fails and I get a closure allocated on each
 iteration of the loop.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to