#2722: <<loop> when compiling with -O option with ghc-6.10.0.20081019
--------------------------------+-------------------------------------------
  Reporter:  uwe                |          Owner:                
      Type:  bug                |         Status:  new           
  Priority:  normal             |      Milestone:  Not GHC       
 Component:  libraries (other)  |        Version:  7.0.1         
Resolution:                     |       Keywords:  arrows        
  Testcase:                     |      Blockedby:                
Difficulty:  Unknown            |             Os:  Linux         
  Blocking:                     |   Architecture:  x86_64 (amd64)
   Failure:  Runtime crash      |  
--------------------------------+-------------------------------------------
Changes (by litoh):

  * status:  closed => new
  * failure:  => Runtime crash
  * version:  6.10.1 => 7.0.1
  * resolution:  fixed =>
  * architecture:  x86 => x86_64 (amd64)


Comment:

 I'm getting the same error with another Arrow library (FRP.Yampa). What's
 strange though is that the error disappears under certain circumstances:

 # use Bool instead of Event () for input type
 # use Int instead of (String, Int) for output type
 # -
 # inline constant function

 WTF? :)

 {{{
 {-# LANGUAGE Arrows #-}

 module Main (main) where

 import FRP.Yampa

 type ObjIn = Event () -- loop #1
 --type ObjIn = Bool -- no loop #1

 type ObjOut = (String, Int) -- loop #2
 --type ObjOut = Int         -- no loop #2

 type GameObj = SF ObjIn ObjOut

 testObj :: GameObj
 testObj = proc hit -> do
     returnA -< ("testObj", 1) -- loop #2
 --    returnA -< 1            -- no loop #2

 process :: [GameObj] -> SF () [ObjOut]
 process objs = proc _ -> do
     rec
         gamestate <- par logic objs
             -< gamestate -- loop #3 (recursive definition!)
 --            -< [] -- no loop #3

     returnA -< gamestate

 logic :: [ObjOut] -> [sf] -> [(ObjIn, sf)]
 logic gamestate objs = map route objs
   where
     route obj =
         (if null (foo gamestate) then NoEvent else NoEvent, obj) -- loop
 #1
 --        (if null (foo gamestate) then False else False, obj) -- no loop
 #1

 foo :: [ObjOut] -> [ObjOut]
 foo [] = []
 foo objs = concat (collisions objs)
   where
     collisions [] = []
     collisions (out:objs') =
         [[out, out'] | out' <- objs, out `collide` out'] -- loop #4
 --        [[out, out'] | out' <- objs, True] -- no loop #4

 collide :: ObjOut -> ObjOut -> Bool
 collide (_, p) (_, p') = True -- loop #2
 --collide p p' = True         -- no loop #2


 main :: IO ()
 main = do
     putStrLn . show $ embed (process [testObj]) ((), [(1.0, Nothing)])
 }}}

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to