Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ProgressBar = ProgressBar {
- pgInfo :: ProgressBarInfo
- pgFuture :: Async ()
- pgRegion :: ConsoleRegion
- data Options = Options {
- pgFormat :: String
- pgCompletedChar :: Char
- pgPendingChar :: Char
- pgTotal :: Integer
- pgWidth :: Int
- pgOnCompletion :: Maybe String
- pgGetProgressStr :: Options -> Stats -> String
- data Stats = Stats {}
- isComplete :: ProgressBar -> IO Bool
- newProgressBar :: Options -> IO ProgressBar
- complete :: ProgressBar -> IO ()
- tick :: ProgressBar -> IO ()
- tickN :: ProgressBar -> Int -> IO ()
- tickNI :: ProgressBar -> Integer -> IO ()
- getProgressStrIO :: ProgressBar -> IO String
- getProgressStats :: ProgressBar -> IO Stats
- getProgressStr :: Options -> Stats -> String
- class Default a where
- def :: a
- module System.Console.Regions
Documentation
data ProgressBar Source
ProgressBar | |
|
The progress bar's options.
Options | |
|
Represents a point in time for the progress bar.
isComplete :: ProgressBar -> IO Bool Source
Returns if the progress bar rendering thread has exited (it has done enough ticks)
newProgressBar :: Options -> IO ProgressBar Source
Creates a new progress bar with the given Options
. Multiple progress bars
may be created. This package depends on `concurrent-output`, so it's --
necessary that progress-bar usage is wrapped with a call to
displayConsoleRegions
.
import Control.Concurrent (threadDelay) import Control.Monad (unless) import System.Console.AsciiProgress main :: IO () main = displayConsoleRegions $ do pg <- newProgressBar def { pgWidth = 100 , pgOnCompletion = Just "Done :percent after :elapsed seconds" } loop pg where loop pg = do b <- isComplete pg unless b $ do threadDelay $ 200 * 1000 tick pg loop pg
complete :: ProgressBar -> IO () Source
Forces a ProgressBar
to finish
tick :: ProgressBar -> IO () Source
Tick the progress bar
tickN :: ProgressBar -> Int -> IO () Source
Tick the progress bar N times
tickNI :: ProgressBar -> Integer -> IO () Source
Tick the progress bar N times
getProgressStrIO :: ProgressBar -> IO String Source
Like getProgressStr
but works on the ProgressBar
object and uses the IO
monad.
getProgressStats :: ProgressBar -> IO Stats Source
Gets the progress bar current Stats
object
getProgressStr :: Options -> Stats -> String Source
Gets the string to be printed given the options object and a certain stats object representing the rendering moment.
class Default a where
A class for types with a default value.
def :: a
The default value for this type.
module System.Console.Regions