Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data WatchState = WatchState {
- wsTable :: Table
- wsUpdateTime :: Maybe UTCTime
- initWatchState :: WatchState
- handleWatch :: Bool -> IO (Either CodeforcesError Table) -> IO ()
- watchTable :: Int -> IO (Either CodeforcesError Table) -> StateT WatchState IO ()
- addInfo :: Table -> Maybe CodeforcesError -> UTCTime -> Maybe UTCTime -> Table
- truncateTable :: Table -> Maybe Int -> Table
- resetScreen :: IO ()
- withDisabledStdin :: IO a -> IO a
Documentation
data WatchState Source #
Values used for watching output.
handleWatch :: Bool -> IO (Either CodeforcesError Table) -> IO () Source #
handleWatch
shouldWatch m
runs computation m
once if shouldWatch
is
false, otherwise watchTable
watches it.
In the latter case, it clears the terminal and sets up terminal behaviour for watching data.
:: Int | Delay, in seconds. |
-> IO (Either CodeforcesError Table) | Fetches an updated table. |
-> StateT WatchState IO () | Data from previous iteration. |
watchTable
delaySecs m
runs computation m
every delaySecs
amount of
seconds. The terminal output from m
is changed if the next run of m
yields a different result.
:: Table | Table to modify. |
-> Maybe CodeforcesError | Error message, if exists. |
-> UTCTime | Current system time. |
-> Maybe UTCTime | Last successful update time, if any. |
-> Table |
Takes a table with a potential error message and last successful update time, and returns the table with extra rows for various messages.
When tables are displayed in watch mode, these extra rows are placed before the table: * The first displays a message for how to exit watch mode. * The second row displays errors if there are any and the last update time. * The third row is blank.
truncateTable :: Table -> Maybe Int -> Table Source #
truncateTable
table x
returns the table with the first x
rows, or the
original table if x
is Nothing
.
resetScreen :: IO () Source #
withDisabledStdin :: IO a -> IO a Source #
Prevents any input into the terminal while running the IO computation.