Extra-1.29: A grab bag of modules.Source codeContentsIndex
Extra.CIO
Contents
The CIO class
Style constructors and transformers
Output functions
Description
CIO is a type class for the TIO monad, which tracks the cursor position of the console so that indentation and prefixes can be added to the output. TIO also has a style component which lets you control the output verbosity and the appearance of the prefix. There is an instance for the regular IO monad which doesn't use any of these features, to allow functions which do not use the TIO monad call functions in the Debian library.
Synopsis
class MonadIO m => CIO m where
hPutStr :: Handle -> String -> m ()
hBOL :: Handle -> m ()
ev :: Int -> m Int
setStyle :: (TStyle -> TStyle) -> m a -> m a
tryCIO :: m a -> m (Either Exception a)
data TStyle = TStyle {
prefix :: String
verbosity :: Int
hPrefix :: [(Handle, String)]
}
defStyle :: TStyle
withStyle :: CIO m => TStyle -> m a -> m a
setVerbosity :: Int -> TStyle -> TStyle
addVerbosity :: Int -> TStyle -> TStyle
setPrefix :: String -> TStyle -> TStyle
addPrefix :: String -> TStyle -> TStyle
appPrefix :: String -> TStyle -> TStyle
setPrefixes :: String -> String -> TStyle -> TStyle
addPrefixes :: String -> String -> TStyle -> TStyle
appPrefixes :: String -> String -> TStyle -> TStyle
hGetPrefix :: Handle -> TStyle -> String
putStr :: CIO m => String -> m ()
ePutStr :: CIO m => String -> m ()
vPutStr :: CIO m => Int -> String -> m ()
vEPutStr :: CIO m => Int -> String -> m ()
hPutChar :: CIO m => Handle -> Char -> m ()
putChar :: CIO m => Char -> m ()
ePutChar :: CIO m => Char -> m ()
vHPutChar :: CIO m => Handle -> Int -> Char -> m ()
vPutChar :: CIO m => Int -> Char -> m ()
vEPutChar :: CIO m => Int -> Char -> m ()
hPutStrBl :: CIO m => Handle -> String -> m ()
putStrBl :: CIO m => String -> m ()
ePutStrBl :: CIO m => String -> m ()
vHPutStrBl :: CIO m => Handle -> Int -> String -> m ()
vPutStrBl :: CIO m => Int -> String -> m ()
vEPutStrBl :: CIO m => Int -> String -> m ()
hPutStrLn :: CIO m => Handle -> String -> m ()
putStrLn :: CIO m => String -> m ()
ePutStrLn :: CIO m => String -> m ()
vHPutStrLn :: CIO m => Handle -> Int -> String -> m ()
vPutStrLn :: CIO m => Int -> String -> m ()
vEPutStrLn :: CIO m => Int -> String -> m ()
bol :: CIO m => m ()
eBOL :: CIO m => m ()
vHBOL :: CIO m => Handle -> Int -> m ()
vBOL :: CIO m => Int -> m ()
vEBOL :: CIO m => Int -> m ()
The CIO class
class MonadIO m => CIO m whereSource
Class representing ways of doing console (terminal?) output.
Methods
hPutStr :: Handle -> String -> m ()Source
Write output to a handle.
hBOL :: Handle -> m ()Source
If we are not already at the beginning of a line, move the cursor to the beginning of the next one.
ev :: Int -> m IntSource
Return the "effective verbosity" for a task. If the argument is 2 it means the caller is computing ev for a task that normally does output when the verbosity level is 2 or higher. If the verbosity of the current style is 1, then the ev or effective verbosity is 2-1 = -1, so the output should be quieter.
setStyle :: (TStyle -> TStyle) -> m a -> m aSource
Modify the current output style.
tryCIO :: m a -> m (Either Exception a)Source
Implementation of try for this monad
show/hide Instances
Style constructors and transformers
data TStyle Source

A record used to hold the output style information for a task. This The prefixes that will appear at the beginning of each line, and the desired verbosity level. Suggested verbosity level policy:

  • -1: No output of any kind, as if you were directing all output to devnull
  • 0: Error output only, suitable for a run whose log you might examine later
  • 1: casual progress reporting - if you were running on a console but didn't expect anything to go wrong
  • 2: detailed progress reporting - show more progress, particularly things that might fail during the normal operation of the autobuilder: patches that fail to apply, dpkg-buildpackage runs that return errors, etc.
  • 3: Debugging output - use this level or higher if you suspect the autobuilder itself is failing, or you are doing development work on the autobuilder.
Constructors
TStyle
prefix :: StringAdd this string at the beginning of each line
verbosity :: IntIgnore v functions whose argument is more than this
hPrefix :: [(Handle, String)]Per-handle prefix
show/hide Instances
defStyle :: TStyleSource
withStyle :: CIO m => TStyle -> m a -> m aSource
Use a new style for the TIO action
setVerbosity :: Int -> TStyle -> TStyleSource
addVerbosity :: Int -> TStyle -> TStyleSource
setPrefix :: String -> TStyle -> TStyleSource
Set the output style for a handle to prefixed.
addPrefix :: String -> TStyle -> TStyleSource
Prepend some text to the prefix.
appPrefix :: String -> TStyle -> TStyleSource
Append some text to the prefix.
setPrefixes :: String -> String -> TStyle -> TStyleSource
Set the output style for the stdout and stderr handle to prefixed, using whatever prefixes were most recently set (default is [1] and [2].)
addPrefixes :: String -> String -> TStyle -> TStyleSource
Switch to prefixed mode and modify both the stdout and stderr prefixes.
appPrefixes :: String -> String -> TStyle -> TStyleSource
hGetPrefix :: Handle -> TStyle -> StringSource
Get the current prefix for a particular handle
Output functions
putStr :: CIO m => String -> m ()Source
Write a string to stdout.
ePutStr :: CIO m => String -> m ()Source
Write a string to stderr.
vPutStr :: CIO m => Int -> String -> m ()Source
Write a string to stdout depending on the verbosity level.
vEPutStr :: CIO m => Int -> String -> m ()Source
Verbosity controlled version of ePutStr
hPutChar :: CIO m => Handle -> Char -> m ()Source
Write a character.
putChar :: CIO m => Char -> m ()Source
Write a character to stdout.
ePutChar :: CIO m => Char -> m ()Source
Write a character to stderr.
vHPutChar :: CIO m => Handle -> Int -> Char -> m ()Source
Verbosity controlled version of hPutChar.
vPutChar :: CIO m => Int -> Char -> m ()Source
Verbosity controlled version of putChar
vEPutChar :: CIO m => Int -> Char -> m ()Source
Verbosity controlled version of ePutChar
hPutStrBl :: CIO m => Handle -> String -> m ()Source
Move to beginning of next line (if necessary) and output a string.
putStrBl :: CIO m => String -> m ()Source
hPutStrBl to stdout.
ePutStrBl :: CIO m => String -> m ()Source
hPutStrBl to stderr.
vHPutStrBl :: CIO m => Handle -> Int -> String -> m ()Source
Verbosity controlled version of hPutStrBl
vPutStrBl :: CIO m => Int -> String -> m ()Source
Verbosity controlled version of putStrBl
vEPutStrBl :: CIO m => Int -> String -> m ()Source
Verbosity controlled version of ePutStrBl
hPutStrLn :: CIO m => Handle -> String -> m ()Source
Write a newline character and a string.
putStrLn :: CIO m => String -> m ()Source
hPutStrLn to stdout.
ePutStrLn :: CIO m => String -> m ()Source
hPutStrLn to stderr.
vHPutStrLn :: CIO m => Handle -> Int -> String -> m ()Source
Verbosity controlled version of hPutStrLn.
vPutStrLn :: CIO m => Int -> String -> m ()Source
Verbosity controlled version of putStrLn
vEPutStrLn :: CIO m => Int -> String -> m ()Source
Verbosity controlled version of ePutStrLn
bol :: CIO m => m ()Source
hBOL to stdout.
eBOL :: CIO m => m ()Source
hBOL to stderr.
vHBOL :: CIO m => Handle -> Int -> m ()Source
vBOL :: CIO m => Int -> m ()Source
Verbosity controlled version of BOL
vEBOL :: CIO m => Int -> m ()Source
Verbosity controlled version of eBOL
Produced by Haddock version 2.6.0