-
Notifications
You must be signed in to change notification settings - Fork 15
Readme
You can help improve this README with extra snippets and advice by using the GitHub wiki.
To just install the library:
runghc Setup.lhs configure
runghc Setup.lhs build
sudo runghc Setup.lhs install
If you want to build the example, to check it’s all working:
runghc Setup.lhs configure -fexample
runghc Setup.lhs build
dist/build/ansi-wl-pprint-example/ansi-wl-pprint-example
A pretty printing library based on Wadler’s paper “A Prettier Printer”. It has been enhanced with support for ANSI terminal colored output using the ansi-terminal package.
This package is extensively based on Daan Leijen’s excellent wl-pprint library.
A full example is provided with the package, and can be compiled by suppling Cabal with the -fexample
flag. It is also available online at GitHub.
The library provides the obvious API, which just allows colorization of any Doc
value. It looks something like this:
-- | Displays a document with the given forecolor
black, red, green, yellow, blue, magenta, cyan, white,
dullblack, dullred, dullgreen, dullyellow,
dullblue, dullmagenta, dullcyan, dullwhite :: Doc -> Doc
-- | Displays a document with a forecolor given in the first parameter
color, dullcolor :: Color -> Doc -> Doc
-- | Displays a document with the given backcolor
onblack, onred, ongreen, onyellow, onblue, onmagenta, oncyan, onwhite,
ondullblack, ondullred, ondullgreen, ondullyellow,
ondullblue, ondullmagenta, ondullcyan, ondullwhite :: Doc -> Doc
-- | Displays a document with a backcolor given in the first parameter
oncolor, ondullcolor :: Color -> Doc -> Doc
The putDoc
and hPutDoc
functions are fully portable between Windows and Unix-like operating systems with ANSI terminals.
If you output Doc
via a String
(i.e. using show
), no colored text will be displayed on Windows, though it will work fine on Unix. This is to due to a technical limitation on how ANSI colors are implemented on Windows consoles.