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


-- | A simple progress bar for the console.
--   
--   A simple Haskell progress bar for the console. Heavily borrows from TJ
--   Holowaychuk's Node.JS project <a>progress</a>
--   
--   <a>github</a>
@package ascii-progress
@version 0.3.3.0

module System.Console.AsciiProgress.Internal

-- | The progress bar's options.
data Options
Options :: String -> Char -> Char -> Integer -> Int -> Maybe String -> (Options -> Stats -> String) -> Options

-- | A format string for the progress bar. Currently the following format
--   strings are supported: - ":eta" (ETA displayed in seconds) -
--   ":current" (current tick) - ":total" (total number of ticks) -
--   ":percent" (percentage completed) - ":elapsed" (elapsed time in
--   seconds) - ":bar" (the actual progress bar)
[pgFormat] :: Options -> String

-- | Character to be used on the completed part of the bar
[pgCompletedChar] :: Options -> Char

-- | Character to be used on the pending part of the bar
[pgPendingChar] :: Options -> Char

-- | Total amount of ticks expected
[pgTotal] :: Options -> Integer

-- | The progress bar's width
[pgWidth] :: Options -> Int

-- | What to output when the progress bar is done. The same format
--   placeholders used in <a>pgFormat</a> may be used.
[pgOnCompletion] :: Options -> Maybe String
[pgGetProgressStr] :: Options -> Options -> Stats -> String

-- | The progress bar's state object. Contains all but the printing
--   thread's <tt>Async</tt> object.
data ProgressBarInfo
ProgressBarInfo :: Options -> Chan Integer -> MVar Integer -> MVar UTCTime -> ProgressBarInfo
[pgOptions] :: ProgressBarInfo -> Options
[pgChannel] :: ProgressBarInfo -> Chan Integer
[pgCompleted] :: ProgressBarInfo -> MVar Integer
[pgFirstTick] :: ProgressBarInfo -> MVar UTCTime

-- | Represents a point in time for the progress bar.
data Stats
Stats :: Integer -> Integer -> Integer -> Double -> Double -> Double -> Stats
[stTotal] :: Stats -> Integer
[stCompleted] :: Stats -> Integer
[stRemaining] :: Stats -> Integer
[stElapsed] :: Stats -> Double
[stPercent] :: Stats -> Double
[stEta] :: Stats -> Double

-- | Creates a new empty progress bar info object.
newProgressBarInfo :: Options -> IO ProgressBarInfo

-- | Gets the string to be printed given the options object and a certain
--   stats object representing the rendering moment.
getProgressStr :: Options -> Stats -> String

-- | Creates a stats object for a given <tt>ProgressBarInfo</tt> node. This
--   is the core logic, isolated, and may be used to make the same analysis
--   code to be used by different progress renderers.
getInfoStats :: ProgressBarInfo -> IO Stats

-- | Generates the actual progress bar string, with its completed/pending
--   characters, width and a completeness percentage.
getBar :: Char -> Char -> Int -> Double -> String

-- | Gets the amount of seconds elapsed between two <tt>UTCTime</tt>s as a
--   double.
getElapsed :: UTCTime -> UTCTime -> Double

-- | Gets the ETA, given the elapsed time and the amount of completed and
--   remaining ticks.
--   
--   <pre>
--   &gt;&gt;&gt; getEta 50 50 10.0
--   10.0
--   
--   &gt;&gt;&gt; getEta 30 70 23.3
--   54.366666666666674
--   </pre>
getEta :: Integer -> Integer -> Double -> Double

-- | Replaces each pair in a list of replacement pairs in a list with
--   replace. The idea is to call <tt>((old, new) target -&gt; replace old
--   new target)</tt> on each of the pairs, accumulating the resulting
--   modified list.
--   
--   <pre>
--   &gt;&gt;&gt; replaceMany [] "foobar"
--   "foobar"
--   
--   &gt;&gt;&gt; replaceMany [("bar", "biz")] "foobar"
--   "foobiz"
--   
--   &gt;&gt;&gt; replaceMany [("foo", "baz"), ("bar", "biz")] "foobar"
--   "bazbiz"
--   </pre>
replaceMany :: Eq a => [([a], [a])] -> [a] -> [a]

-- | Replaces a subsequence by another in a sequence
--   
--   Taken from <a>http://bluebones.net/2007/01/replace-in-haskell/</a>
--   
--   <pre>
--   &gt;&gt;&gt; replace "foo" "baz" "foobar"
--   "bazbar"
--   
--   &gt;&gt;&gt; replace "some" "thing" "something something"
--   "thingthing thingthing"
--   
--   &gt;&gt;&gt; replace "not" "" "something"
--   "something"
--   
--   &gt;&gt;&gt; replace "" "here" "something"
--   "heresomething"
--   </pre>
replace :: Eq a => [a] -> [a] -> [a] -> [a]

-- | Forces an MVar's contents to be read or swaped by a default value,
--   even if it's currently empty. Will discard the default value write to
--   the MVar if it becomes full in the middle of the operation and return
--   its value. It's assumed that once the MVar becomes full, it won't ever
--   be left emptied. This code may deadlock if that's the case.
forceReadMVar :: MVar a -> a -> IO a
instance Data.Default.Class.Default System.Console.AsciiProgress.Internal.Options

module System.Console.AsciiProgress
data ProgressBar
ProgressBar :: ProgressBarInfo -> Async () -> ConsoleRegion -> ProgressBar
[pgInfo] :: ProgressBar -> ProgressBarInfo
[pgFuture] :: ProgressBar -> Async ()
[pgRegion] :: ProgressBar -> ConsoleRegion

-- | The progress bar's options.
data Options
Options :: String -> Char -> Char -> Integer -> Int -> Maybe String -> (Options -> Stats -> String) -> Options

-- | A format string for the progress bar. Currently the following format
--   strings are supported: - ":eta" (ETA displayed in seconds) -
--   ":current" (current tick) - ":total" (total number of ticks) -
--   ":percent" (percentage completed) - ":elapsed" (elapsed time in
--   seconds) - ":bar" (the actual progress bar)
[pgFormat] :: Options -> String

-- | Character to be used on the completed part of the bar
[pgCompletedChar] :: Options -> Char

-- | Character to be used on the pending part of the bar
[pgPendingChar] :: Options -> Char

-- | Total amount of ticks expected
[pgTotal] :: Options -> Integer

-- | The progress bar's width
[pgWidth] :: Options -> Int

-- | What to output when the progress bar is done. The same format
--   placeholders used in <a>pgFormat</a> may be used.
[pgOnCompletion] :: Options -> Maybe String
[pgGetProgressStr] :: Options -> Options -> Stats -> String

-- | Represents a point in time for the progress bar.
data Stats
Stats :: Integer -> Integer -> Integer -> Double -> Double -> Double -> Stats
[stTotal] :: Stats -> Integer
[stCompleted] :: Stats -> Integer
[stRemaining] :: Stats -> Integer
[stElapsed] :: Stats -> Double
[stPercent] :: Stats -> Double
[stEta] :: Stats -> Double

-- | Returns if the progress bar rendering thread has exited (it has done
--   enough ticks)
isComplete :: ProgressBar -> IO Bool

-- | Creates a new progress bar with the given <tt>Options</tt>. 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 <a>displayConsoleRegions</a>.
--   
--   <pre>
--   import           Control.Concurrent           (threadDelay)
--   import           Control.Monad                (unless)
--   import           System.Console.AsciiProgress
--   
--   main :: IO ()
--   main = displayConsoleRegions $ do
--      pg &lt;- newProgressBar def { pgWidth = 100
--                               , pgOnCompletion = Just "Done :percent after :elapsed seconds"
--                               }
--      loop pg
--    where
--      loop pg = do
--          b &lt;- isComplete pg
--          unless b $ do
--              threadDelay $ 200 * 1000
--              tick pg
--              loop pg
--   </pre>
newProgressBar :: Options -> IO ProgressBar

-- | Forces a <a>ProgressBar</a> to finish
complete :: ProgressBar -> IO ()

-- | Tick the progress bar
tick :: ProgressBar -> IO ()

-- | Tick the progress bar N times
tickN :: ProgressBar -> Int -> IO ()

-- | Tick the progress bar N times
tickNI :: ProgressBar -> Integer -> IO ()

-- | Like <tt>getProgressStr</tt> but works on the <tt>ProgressBar</tt>
--   object and uses the IO monad.
getProgressStrIO :: ProgressBar -> IO String

-- | Gets the progress bar current <tt>Stats </tt>object
getProgressStats :: ProgressBar -> IO Stats

-- | Gets the string to be printed given the options object and a certain
--   stats object representing the rendering moment.
getProgressStr :: Options -> Stats -> String

-- | A class for types with a default value.
class Default a

-- | The default value for this type.
def :: Default a => a
