| Copyright | (c) Serokell, 2016 |
|---|---|
| License | GPL-3 (see the file LICENSE) |
| Maintainer | Serokell <hi@serokell.io> |
| Stability | experimental |
| Portability | POSIX, GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
Control.TimeWarp.Timed
Description
This module provides time- and thread-management capabilities. It allows to write scenarios over multithreaded systems, which can then be launched as either real program or emulation with no need to wait for delays.
Example:
example :: MonadTimed m => m ()
example = do
schedule (at 10 minute) $ do
time <- toMicroseconds <$> virtualTime
liftIO $ putStrLn $ "Hello! It's " ++ show time ++ " now"
wait (for 9 minute)
liftIO $ putStrLn "One more minute..."
Such scenario can be launched in real mode using
>>>runTimedIO example<9 minutes passed> One more minute... <1 more minute passed> Hello! It's 600000000µs now
and like emulation via
>>>runTimedT exampleOne more minute... Hello! It's 600000000µs now
which works on the spot.
Documentation
module Control.TimeWarp.Timed.Misc