sr-extra-1.46.3.2: A grab bag of modules.

Safe HaskellSafe
LanguageHaskell98

Extra.CIO

Contents

Description

Deprecated: Use System.Unix.QIO in Unixutils.

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.

NOTE: a copy of this library is in the Extra library as well. Please update both locations.

This code is provided for backwards compatibility, I don't endorse its use in new projects.

Synopsis

The CIO class

class MonadIO m => CIO m where Source

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 Int Source

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 a Source

Modify the current output style.

tryCIO :: m a -> m (Either SomeException a) Source

Implementation of try for this monad

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 

Fields

prefix :: String

Add this string at the beginning of each line

verbosity :: Int

Ignore v functions whose argument is more than this

hPrefix :: [(Handle, String)]

Per-handle prefix

Instances

withStyle :: CIO m => TStyle -> m a -> m a Source

Use a new style for the TIO action

setPrefix :: String -> TStyle -> TStyle Source

Set the output style for a handle to prefixed.

addPrefix :: String -> TStyle -> TStyle Source

Prepend some text to the prefix.

appPrefix :: String -> TStyle -> TStyle Source

Append some text to the prefix.

setPrefixes :: String -> String -> TStyle -> TStyle Source

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 -> TStyle Source

Switch to prefixed mode and modify both the stdout and stderr prefixes.

hGetPrefix :: Handle -> TStyle -> String Source

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

blue :: [Char] -> [Char] Source

green :: [Char] -> [Char] Source

red :: [Char] -> [Char] Source