ANSI Escape Sequence Text Decoration Made Easy https://github.com/EarthCitizen/escape-artist#readme
|Latest on Hackage:||1.1.0|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
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
output to terminal or converted to
String using the provided functions.
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
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
ToEscapable. See the section Explicitly Derived Typeable in the documentation.
See comprehensive documentation with many examples here: