Wadler/Leijen pretty-printer for Haskell, Text-based, with annotations and pluggable backends
open sourceBSD-2-Clausefree
prettyprinter is a Haskell pretty-printing library in the Wadler/Leijen tradition: you build a document from small pieces, a layouter fits it to the available width, and a backend renders it as plain Text, to an ANSI terminal (prettyprinter-ansi-terminal) or to a format of your own. It uses Text throughout instead of String, avoids the name clashes of the older wl-pprint API, and lets documents carry annotations such as styling, links or source locations at no cost when unused. The README is itself generated with the library.
Problems it solves
- pretty-print a syntax tree in Haskell so long lines wrap neatly
- print coloured, aligned output to the terminal from a Haskell program
- replace wl-pprint without its operator name clashes
Features
- Layouts that fit the output width, with alignment, grouping and separators
- Text-based throughout, with no String definitions
- Annotations for styling, links or source locations, free when unused
- ANSI terminal backend in prettyprinter-ansi-terminal; other backends are small to write
- Runnable examples throughout the documentation
