#4509: System.Timeout inoperative with Data.IORef
---------------------------------+------------------------------------------
    Reporter:  warren            |       Owner:                
        Type:  bug               |      Status:  new           
    Priority:  normal            |   Component:  Runtime System
     Version:  7.0.1             |    Keywords:                
    Testcase:                    |   Blockedby:                
          Os:  Unknown/Multiple  |    Blocking:                
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown  
---------------------------------+------------------------------------------

Comment(by warren):

 Code with formatting this time:

 {{{
 import Data.IORef
 import System.Timeout

 fib:: Int -> Int
 fib 0 = 0
 fib 1 = 1
 fib n = fib (n - 1) + fib (n - 2)

 runFibs accum i = do
   let v = fib i
   modifyIORef accum (\l -> (i,v):l)
   --putStrLn $ show (i, v)  -- add this back, and it works
   runFibs accum (i+1)

 main = do
   accum <- newIORef []
   timeout 10000 (runFibs accum 1)
   rv <- readIORef accum
   putStrLn $ show rv
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4509#comment:3>
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