packages feed

leaky-0.1.0.0: leaky-min-cppd.hs

  -- This leaks with GHC 7.8.3 -O2, strict field notwithstanding.

  duration = 5000000  -- XXX tune for your hardware
  period = duration `div` 10

  data State = St !Bool
  toggle (St b) = St (not b)

  main = do
    putStrLn "Leaky started."
    rslt <- duty (St False) 0
    (return $! rslt) >>= return
    putStrLn "Finished."

  duty :: State -> Int -> IO State
  duty state i = do
    let state' = toggle state
    if 0 == i `mod` period then return () else return ()
    if i < duration then duty state' (1+i) else return state'