terminal-progress-bar-0.1.1.1: A simple progress bar in the terminal

Safe HaskellSafe
LanguageHaskell2010

System.ProgressBar

Contents

Synopsis

Progress bars

type ProgressBar a Source #

Arguments

 = 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

type Label Source #

Arguments

 = Integer

Completed amount of work.

-> Integer

Total amount of work.

-> String

Resulting label.

A label that can be pre- or postfixed to a progress bar.

noLabel :: Label Source #

The empty label.

>>> noLabel 30 100
""

msg :: String -> Label Source #

A label consisting of a static string.

>>> msg "foo" 30 100
"foo"

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%"

exact :: Label Source #

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

startProgress Source #

Arguments

:: 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.