Colourista.Pure

colourista-0.1.0.2: Convenient interface for printing colourful messages

Copyright | (c) 2020-2022 Kowainik
License | MPL-2.0
Maintainer | Kowainik <xrom.xkov@gmail.com>
Safe Haskell | None
Language | Haskell2010

Colourista.Pure

Contents

- Colour
- Background
- Emphasis
- Reset

Description

This module introduces helpful pure codes to customise the terminal output view.

Synopsis

- formatWith :: (IsString str, Semigroup str) => [str] -> str -> str
- red :: IsString str => str
- green :: IsString str => str
- blue :: IsString str => str
- yellow :: IsString str => str
- black :: IsString str => str
- white :: IsString str => str
- magenta :: IsString str => str
- cyan :: IsString str => str
- redBg :: IsString str => str
- greenBg :: IsString str => str
- blueBg :: IsString str => str
- yellowBg :: IsString str => str
- blackBg :: IsString str => str
- whiteBg :: IsString str => str
- magentaBg :: IsString str => str
- cyanBg :: IsString str => str
- bold :: IsString str => str
- italic :: IsString str => str
- underline :: IsString str => str
- doubleUnderline :: IsString str => str
- noUnderline :: IsString str => str
- indent :: (IsString str, Semigroup str) => Int -> str
- reset :: IsString str => str

# Documentation

formatWith :: (IsString str, Semigroup str) => [str] -> str -> str #

General purpose function to format strings with multiple options. If this function takes empty list as an argument, no formatting is applied.

Some typical usages include but not limited to:

1. Green text: ``formatWith` [`green`] myString`
2. Bold red text: ``formatWith` [`bold`, `red`] myString`
3. Blue text on white background: ``formatWith` [`blue`, `whiteBg`] myString`
4. Italicized yellow on cyan background: ``formatWith` [`italic`, `yellow`, `cyanBg`] myString`

⚠ Caution: Double underlining `doubleUnderline` is not widely supported. It is also not natively supported on Windows 10.

# Colour

red :: IsString str => str #

Code to apply `Red` colouring for the terminal output.

green :: IsString str => str #

Code to apply `Green` colouring for the terminal output.

blue :: IsString str => str #

Code to apply `Blue` colouring for the terminal output.

yellow :: IsString str => str #

Code to apply `Yellow` colouring for the terminal output.

black :: IsString str => str #

Code to apply `Black` colouring for the terminal output.

white :: IsString str => str #

Code to apply `White` colouring for the terminal output.

magenta :: IsString str => str #

Code to apply `Magenta` colouring for the terminal output.

cyan :: IsString str => str #

Code to apply `Cyan` colouring for the terminal output.

# Background

redBg :: IsString str => str #

Code to apply `Red` background colouring for the terminal output.

greenBg :: IsString str => str #

Code to apply `Green` background colouring for the terminal output.

blueBg :: IsString str => str #

Code to apply `Blue` background colouring for the terminal output.

yellowBg :: IsString str => str #

Code to apply `Yellow` background colouring for the terminal output.

blackBg :: IsString str => str #

Code to apply `Black` background colouring for the terminal output.

whiteBg :: IsString str => str #

Code to apply `White` background colouring for the terminal output.

magentaBg :: IsString str => str #

Code to apply `Magenta` background colouring for the terminal output.

cyanBg :: IsString str => str #

Code to apply `Cyan` background colouring for the terminal output.

# Emphasis

bold :: IsString str => str #

Code to apply bold emphasis for the terminal output.

italic :: IsString str => str #

Code to apply italic emphasis for the terminal output.

underline :: IsString str => str #

Code to apply underline emphasis for the terminal output.

doubleUnderline :: IsString str => str #

Code to apply double underline emphasis for the terminal output.

⚠ Caution: This is not widely supported. It is not natively supported on Windows 10

noUnderline :: IsString str => str #

Code to apply no underline emphasis for the terminal output.

indent :: (IsString str, Semigroup str) => Int -> str #

Code to indent the terminal output by the given amount of spaces.

# Reset

reset :: IsString str => str #

Code to reset all previous code applied for the terminal output.