escape-artist: ANSI Escape Sequence Text Decoration Made Easy

[ bsd3, library, text ] [ Propose Tags ]

A library for text decoration with ANSI escape sequences made easy. Decorate your terminal text expressively. Any complex data type, existing or custom, can be simply colorized by implementing the class ToEscapable, then output to terminal or converted to String using the provided functions.

Simple Example

import Data.Monoid ((<>))
import Text.EscapeArtist

underlines = Underline $ FgCyan "I am underlined" <> UnderlineOff " but I am not " <> FgMagenta "and I am over here"

putEscLn underlines

Implementing ToEscapable

import Data.Monoid ((<>))
import Text.EscapeArtist

data ABC = A | B deriving (Show, Eq)

instance ToEscapable ABC where
    toEscapable (A) = FgRed $ show A
    toEscapable (B) = FgGreen $ show B

instance (ToEscapable a) => ToEscapable (Maybe a) where
     toEscapable (Just a) = FgGreen "Just" <> Inherit " " <> FgYellow a
     toEscapable a = FgRed $ show a

NOTE: For GHC < 7.10 you will also need to explicitly derive Typeable for custom data types implementing ToEscapable. See the section Explicitly Derived Typeable in the documentation.

Comprehensive Documentation

See comprehensive documentation with many examples here:

Versions [faq] 1.0.0, 1.1.0
Dependencies base (>= && <5), bytestring (>= && <0.11), text (>= && <1.3) [details]
License BSD-3-Clause
Copyright 2016 Ryan Daniels
Author Ryan Daniels
Category Text
Home page
Source repo head: git clone
Uploaded by ryan_daniels at Tue Jan 24 10:33:30 UTC 2017
Distributions NixOS:1.1.0
Downloads 691 total (8 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2017-01-24 [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees