chatty-0.2.0.1: Text/Chatty/Extended/Printer.hs
-- | Provides an extended printer class that supports colours.
module Text.Chatty.Extended.Printer where
import Text.Chatty.Printer
-- | Colour tone.
data Tone = Green | Red | Yellow | Blue | Black | White | Cyan | Magenta
-- | Colour brightness
data Colour = Dull Tone | Vivid Tone
-- | Typeclass for all printers that support colourized output.
class MonadPrinter m => ExtendedPrinter m where
-- | Run the function with the given colour.
ebracket :: Colour -> m a -> m a
ebracket c m = do estart c; a <- m; efin; return a
-- | Print the string in the given colour.
eprint :: Colour -> String -> m ()
eprint c = ebracket c . mprint
-- | Print the string in the given colour and terminate the line.
eprintLn :: Colour -> String -> m ()
eprintLn c s = eprint c s >> mprintLn ""
-- | Start using the specified colour.
estart :: Colour -> m ()
-- | Reset colour.
efin :: m ()