Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- type ProgressBar a = Label -> Label -> Integer -> Integer -> Integer -> a
- progressBar :: ProgressBar (IO ())
- hProgressBar :: Handle -> ProgressBar (IO ())
- mkProgressBar :: ProgressBar String
- type Label = Integer -> Integer -> String
- noLabel :: Label
- msg :: String -> Label
- percentage :: Label
- exact :: Label
- data ProgressRef
- startProgress :: Label -> Label -> Integer -> Integer -> IO (ProgressRef, ThreadId)
- incProgress :: ProgressRef -> Integer -> IO ()
Progress bars
type ProgressBar a Source #
= Label | Prefixed label. |
-> Label | Postfixed label. |
-> Integer | Total progress bar width in characters. |
-> Integer | Amount of work completed. |
-> Integer | Total amount of work. |
-> a |
Type of functions producing a progress bar.
progressBar :: ProgressBar (IO ()) Source #
Print a progress bar to stderr
See hProgressBar
.
hProgressBar :: Handle -> ProgressBar (IO ()) Source #
Print a progress bar to a file handle.
Erases the current line! (by outputting '\r') Does not print a newline '\n'. Subsequent invocations will overwrite the previous output.
mkProgressBar :: ProgressBar String Source #
Renders a progress bar
>>>
mkProgressBar (msg "Working") percentage 40 30 100
"Working [=======>.................] 30%"
Labels
A label that can be pre- or postfixed to a progress bar.
percentage :: Label Source #
A label which displays the progress as a percentage.
Constant width property: ∀ d t : ℕ. d ≤ t → length (percentage d t) ≡ 4
>>>
percentage 30 100
" 30%"
A label which displays the progress as a fraction of the total amount of work.
Equal width property: ∀ d₁ d₂ t : ℕ. d₁ ≤ d₂ ≤ t → length (exact d₁ t) ≡ length (exact d₂ t)
>>>
exact 30 100
" 30/100"
Auto printing
data ProgressRef Source #
:: Label | Prefixed label. |
-> Label | Postfixed label. |
-> Integer | Total progress bar width in characters. |
-> Integer | Total amount of work. |
-> IO (ProgressRef, ThreadId) |
Start a thread to automatically display progress. Use incProgress to step the progress bar.
incProgress :: ProgressRef -> Integer -> IO () Source #
Increment the progress bar. Negative values will reverse the progress. Progress will never be negative and will silently stop taking data when it completes.