pretty-terminal: Styling and coloring terminal output with ANSI escape sequences.

[ bsd3, library, program, terminal ] [ Propose Tags ]




Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Change log
Dependencies base (>=4.9 && <5), pretty-terminal, text [details]
License BSD-3-Clause
Copyright 2018 Logan McPhail
Author Logan McPhail
Revised Revision 1 made by HerbertValerioRiedel at 2019-02-11T08:21:03Z
Category Terminal
Home page
Bug tracker
Source repo head: git clone
Uploaded by loganmac at 2018-02-03T07:19:10Z
Distributions Fedora:, LTSHaskell:, NixOS:, Stackage:
Reverse Dependencies 17 direct, 9 indirect [details]
Executables example
Downloads 4290 total (39 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-02-03 [all 1 reports]

Readme for pretty-terminal-

[back to package description]



{-# LANGUAGE OverloadedStrings #-}
module Main where

import qualified Data.Text.IO          as T
import           System.Console.Pretty (Color (..), Style (..), bgColor, color,
                                        style, supportsPretty)

main :: IO ()
main = do
  inColor <- supportsPretty
  if inColor then example
             else putStrLn "Sorry, this terminal doesn't support pretty ANSI codes"

example :: IO ()
example = do
  -- simple style
  putStrLn ( style Underline "hello there!" )

  -- simple color
  putStrLn ( color Yellow "this lib was designed to be easy" )

  -- simple background
  putStrLn ( bgColor Blue "and the functions layer together easily" )

  -- combining
  putStrLn ( bgColor White . color Red . style Bold $ "like so!" )

  -- custom style & color
  let primary = bgColor Magenta . color Green . style Italic
  putStrLn ( primary "easily create your own helpers & styles" )

  -- with both unicode string types
  putStrLn ( color Cyan "String...")
  T.putStrLn (color Red "and Text")

  -- set styling to none
  putStrLn ( primary $ style Normal "or if you need to remove any styling..." )