Safe Haskell | Safe-Inferred |
---|
Progress bars
:: Label | Prefixed label. |
-> Label | Postfixed label. |
-> ℤ | Total progress bar width in characters. |
-> ℤ | Amount of work completed. |
-> ℤ | Total amount of work. |
-> IO () |
Print a progress bar
Erases the current line! (by outputting '\r') Does not print a newline '\n'. Subsequent invocations will overwrite the previous output.
Remember to set the correct buffering mode for stdout:
import System.IO ( hSetBuffering, BufferMode(NoBuffering), stdout ) hSetBuffering stdout NoBuffering
:: Label | Prefixed label. |
-> Label | Postfixed label. |
-> ℤ | Total progress bar width in characters. |
-> ℤ | Amount of work completed. |
-> ℤ | Total amount of work. |
-> String |
Renders a progress bar
>>>
mkProgressBar (msg "Working") percentage 40 30 100
"Working [=======>.................] 30%"
Labels
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%"