-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A simple progress bar in the terminal
--   
--   A progress bar is used to convey the progress of a task. This package
--   implements a very simple textual progress bar.
--   
--   See the module <a>System.ProgressBar</a> on how to use the progress
--   bar or build the package with the -fexample flag for a small example
--   program.
--   
--   The animated progress bar depends entirely on the interpretation of
--   the carriage return character ('\r'). If your terminal interprets it
--   as something else than "move cursor to beginning of line", the
--   animation won't work.
@package terminal-progress-bar
@version 0.1.1.1

module System.ProgressBar

-- | Type of functions producing a progress bar.
type ProgressBar a = Label  Prefixed label. -> Label  Postfixed label. -> Integer  Total progress bar width in characters. -> Integer  Amount of work completed. -> Integer  Total amount of work. -> a

-- | Print a progress bar to <a>stderr</a>
--   
--   See <a>hProgressBar</a>.
progressBar :: ProgressBar (IO ())

-- | 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.
hProgressBar :: Handle -> ProgressBar (IO ())

-- | Renders a progress bar
--   
--   <pre>
--   &gt;&gt;&gt; mkProgressBar (msg "Working") percentage 40 30 100
--   "Working [=======&gt;.................]  30%"
--   </pre>
mkProgressBar :: ProgressBar String

-- | A label that can be pre- or postfixed to a progress bar.
type Label = Integer  Completed amount of work. -> Integer  Total amount of work. -> String  Resulting label.

-- | The empty label.
--   
--   <pre>
--   &gt;&gt;&gt; noLabel 30 100
--   ""
--   </pre>
noLabel :: Label

-- | A label consisting of a static string.
--   
--   <pre>
--   &gt;&gt;&gt; msg "foo" 30 100
--   "foo"
--   </pre>
msg :: String -> Label

-- | A label which displays the progress as a percentage.
--   
--   Constant width property: ∀ d t : ℕ. d ≤ t → length (percentage d t) ≡
--   4
--   
--   <pre>
--   &gt;&gt;&gt; percentage 30 100
--   " 30%"
--   </pre>
percentage :: Label

-- | 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)
--   
--   <pre>
--   &gt;&gt;&gt; exact 30 100
--   " 30/100"
--   </pre>
exact :: Label
data ProgressRef

-- | Start a thread to automatically display progress. Use incProgress to
--   step the progress bar.
startProgress :: Label -> Label -> Integer -> Integer -> IO (ProgressRef, ThreadId)

-- | Increment the progress bar. Negative values will reverse the progress.
--   Progress will never be negative and will silently stop taking data
--   when it completes.
incProgress :: ProgressRef -> Integer -> IO ()
