Overview of the prettyprinter library
masterThe prettyprinter library is a modern Wadler/Leijen-style text rendering engine designed for flexible and efficient document formatting. It follows a three-step mental model:
- Compose: Build a complex document out of many small components.
- Layout: Use a layouter to convert the document into a simplified, renderable format.
- Render: Convert the layout into a specific target format, such as plain
Text, Markdown, or ANSI terminal output.
Key features include Text-based internals (avoiding String), support for unobtrusive annotations (for styling or metadata), and extensible backends.
let prettyType = align . sep . zipWith (<+>) ("::" : repeat "->")
prettySig name ty = pretty name <+> prettyType ty
in prettySig "example" ["Int", "Bool", "Char", "IO ()"]