Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Options = Options {
- pgFormat :: String
- pgCompletedChar :: Char
- pgPendingChar :: Char
- pgTotal :: Integer
- pgWidth :: Int
- pgOnCompletion :: Maybe String
- pgGetProgressStr :: Options -> Stats -> String
- data ProgressBarInfo = ProgressBarInfo {}
- data Stats = Stats {}
- newProgressBarInfo :: Options -> IO ProgressBarInfo
- getProgressStr :: Options -> Stats -> String
- getInfoStats :: ProgressBarInfo -> IO Stats
- getBar :: Char -> Char -> Int -> Double -> String
- getElapsed :: UTCTime -> UTCTime -> Double
- getEta :: Integer -> Integer -> Double -> Double
- replaceMany :: Eq a => [([a], [a])] -> [a] -> [a]
- replace :: Eq a => [a] -> [a] -> [a] -> [a]
- forceReadMVar :: MVar a -> a -> IO a
Documentation
The progress bar's options.
Options | |
|
data ProgressBarInfo Source
The progress bar's state object. Contains all but the printing thread's
Async
object.
Represents a point in time for the progress bar.
newProgressBarInfo :: Options -> IO ProgressBarInfo Source
Creates a new empty progress bar info object.
getProgressStr :: Options -> Stats -> String Source
Gets the string to be printed given the options object and a certain stats object representing the rendering moment.
getInfoStats :: ProgressBarInfo -> IO Stats Source
Creates a stats object for a given ProgressBarInfo
node. This is the core
logic, isolated, and may be used to make the same analysis code to be used
by different progress renderers.
getBar :: Char -> Char -> Int -> Double -> String Source
Generates the actual progress bar string, with its completed/pending characters, width and a completeness percentage.
getElapsed :: UTCTime -> UTCTime -> Double Source
Gets the amount of seconds elapsed between two UTCTime
s as a double.
getEta :: Integer -> Integer -> Double -> Double Source
Gets the ETA, given the elapsed time and the amount of completed and remaining ticks.
>>>
getEta 50 50 10.0
10.0>>>
getEta 30 70 23.3
54.366666666666674
replaceMany :: Eq a => [([a], [a])] -> [a] -> [a] Source
Replaces each pair in a list of replacement pairs in a list with replace.
The idea is to call ((old, new) target -> replace old new target)
on each
of the pairs, accumulating the resulting modified list.
>>>
replaceMany [] "foobar"
"foobar">>>
replaceMany [("bar", "biz")] "foobar"
"foobiz">>>
replaceMany [("foo", "baz"), ("bar", "biz")] "foobar"
"bazbiz"
replace :: Eq a => [a] -> [a] -> [a] -> [a] Source
Replaces a subsequence by another in a sequence
Taken from http://bluebones.net/2007/01/replace-in-haskell/
>>>
replace "foo" "baz" "foobar"
"bazbar">>>
replace "some" "thing" "something something"
"thingthing thingthing">>>
replace "not" "" "something"
"something">>>
replace "" "here" "something"
"heresomething"
forceReadMVar :: MVar a -> a -> IO a Source
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.