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.
- class MonadIO m => CIO m where
- data TStyle = TStyle {}
- 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.
hPutStr :: Handle -> String -> m ()Source
Write output to a handle.
If we are not already at the beginning of a line, move the cursor to the beginning of the next one.
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
CIO IO | Use this module to call functions in the CIO module from the regular IO monad. This instance ignores all style and state information. The verbosity controlled output functions will ignore any calls when v is greater than zero. This allows you to call the functions in the haskell-debian package from the regular IO monad. This is in a separate module from CIO so you don't accidentally do a liftIO of some other CIO operation and get this instance. |
CIO TIO | The TIO instance of CIO adds some features to the normal console output. By tracking the cursor position it is able to insert a prefix to each line, and to implement a beginning of line (BOL) function which only adds a newline when the cursor is not already at BOL. It also allows verbosity controlled output, where a verbosity level is stored in the monad state and output requests are given a verbosity which must be greater or equal to the monad's verbosity level for the output to appear. |
Style constructors and transformers
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.
setVerbosity :: Int -> TStyle -> TStyleSource
addVerbosity :: Int -> TStyle -> TStyleSource
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.
hGetPrefix :: Handle -> TStyle -> StringSource
Get the current prefix for a particular handle
Output functions
vPutStr :: CIO m => Int -> String -> m ()Source
Write a string to stdout depending on the verbosity level.
hPutStrBl :: CIO m => Handle -> String -> m ()Source
Move to beginning of next line (if necessary) and output a string.
vHPutStrBl :: CIO m => Handle -> Int -> String -> m ()Source
Verbosity controlled version of hPutStrBl