<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Text.PrettyPrint.ANSI.Leijen</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_Text-PrettyPrint-ANSI-Leijen.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Text-PrettyPrint-ANSI-Leijen.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">ansi-wl-pprint-0.6.7.1: The Wadler/Leijen Pretty Printer for colored ANSI terminal output</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Maintainer</th><td>batterseapower@hotmail.com</td></tr><tr><th>Safe Haskell</th><td>Safe-Infered</td></tr></table><p class="caption">Text.PrettyPrint.ANSI.Leijen</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Documents </a></li><li><a href="#g:2">Basic combinators </a></li><li><a href="#g:3">Alignment </a></li><li><a href="#g:4">Operators </a></li><li><a href="#g:5">List combinators </a></li><li><a href="#g:6">Fillers </a></li><li><a href="#g:7">Bracketing combinators </a></li><li><a href="#g:8">Character documents </a></li><li><a href="#g:9">Colorisation combinators </a></li><li><a href="#g:10">Emboldening combinators </a></li><li><a href="#g:11">Underlining combinators </a></li><li><a href="#g:12">Removing formatting </a></li><li><a href="#g:13">Primitive type documents </a></li><li><a href="#g:14">Pretty class </a></li><li><a href="#g:15">Rendering </a></li><li><a href="#g:16">Undocumented </a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Pretty print module based on Philip Wadler's "prettier printer" </p><pre> "A prettier printer" Draft paper, April 1997, revised March 1998. <a href="http://cm.bell-labs.com/cm/cs/who/wadler/papers/prettier/prettier.ps">http://cm.bell-labs.com/cm/cs/who/wadler/papers/prettier/prettier.ps</a> </pre><p>PPrint is an implementation of the pretty printing combinators described by Philip Wadler (1997). In their bare essence, the combinators of Wadler are not expressive enough to describe some commonly occurring layouts. The PPrint library adds new primitives to describe these layouts and works well in practice. </p><p>The library is based on a single way to concatenate documents, which is associative and has both a left and right unit. This simple design leads to an efficient and short implementation. The simplicity is reflected in the predictable behaviour of the combinators which make them easy to use in practice. </p><p>A thorough description of the primitive combinators and their implementation can be found in Philip Wadler's paper (1997). Additions and the main differences with his original paper are: </p><ul><li> The nil document is called empty. </li><li> The above combinator is called <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:-60--36--62-"><$></a></code>. The operator <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:-60--47--62-"></></a></code> is used for soft line breaks. </li><li> There are three new primitives: <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:align">align</a></code>, <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:fill">fill</a></code> and <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:fillBreak">fillBreak</a></code>. These are very useful in practice. </li><li> Lots of other useful combinators, like <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:fillSep">fillSep</a></code> and <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:list">list</a></code>. </li><li> There are two renderers, <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:renderPretty">renderPretty</a></code> for pretty printing and <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:renderCompact">renderCompact</a></code> for compact output. The pretty printing algorithm also uses a ribbon-width now for even prettier output. </li><li> There are two displayers, <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:displayS">displayS</a></code> for strings and <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:displayIO">displayIO</a></code> for file based output. </li><li> There is a <code><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a></code> class. </li><li> The implementation uses optimised representations and strictness annotations. </li></ul><p>Full documentation for the original wl-pprint library available at <a href="http://www.cs.uu.nl/~daan/download/pprint/pprint.html">http://www.cs.uu.nl/~daan/download/pprint/pprint.html</a>. </p><p>The library has been extended to allow formatting text for output to ANSI style consoles. New combinators allow: </p><ul><li> Control of foreground and background color of text </li><li> The abliity to make parts of the text bold or underlined </li></ul><p>This functionality is, as far as possible, portable across platforms with their varying terminals. However, one thing to be particularly wary of is that console colors will not be displayed on Windows unless the <code><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></code> value is output using the <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:putDoc">putDoc</a></code> function or one of it's friends. Rendering the <code><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></code> to a <code><a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-String.html#t:String">String</a></code> and then outputing <em>that</em> will only work on Unix-style operating systems. </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:Doc">Doc</a> </li><li class="src short"><a href="#v:putDoc">putDoc</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:hPutDoc">hPutDoc</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/GHC-IO-Handle.html#t:Handle">Handle</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:empty">empty</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:char">char</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:text">text</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-60--62-">(<>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:nest">nest</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:line">line</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:linebreak">linebreak</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:group">group</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:softline">softline</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:softbreak">softbreak</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:hardline">hardline</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:flatAlt">flatAlt</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:renderSmart">renderSmart</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Float">Float</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a></li><li class="src short"><a href="#v:align">align</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:hang">hang</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:indent">indent</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:encloseSep">encloseSep</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:list">list</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:tupled">tupled</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:semiBraces">semiBraces</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-60--43--62-">(<+>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-60--36--62-">(<$>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-60--47--62-">(</>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-60--36--36--62-">(<$$>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-60--47--47--62-">(<//>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:hsep">hsep</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:vsep">vsep</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:fillSep">fillSep</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:sep">sep</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:hcat">hcat</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:vcat">vcat</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:fillCat">fillCat</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:cat">cat</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:punctuate">punctuate</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>]</li><li class="src short"><a href="#v:fill">fill</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:fillBreak">fillBreak</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:enclose">enclose</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:squotes">squotes</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dquotes">dquotes</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:parens">parens</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:angles">angles</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:braces">braces</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:brackets">brackets</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:lparen">lparen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rparen">rparen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:langle">langle</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rangle">rangle</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:lbrace">lbrace</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rbrace">rbrace</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:lbracket">lbracket</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rbracket">rbracket</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:squote">squote</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dquote">dquote</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:semi">semi</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:colon">colon</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:comma">comma</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:space">space</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dot">dot</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:backslash">backslash</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:equals">equals</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:black">black</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:red">red</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:green">green</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:yellow">yellow</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:blue">blue</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:magenta">magenta</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:cyan">cyan</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:white">white</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dullblack">dullblack</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dullred">dullred</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dullgreen">dullgreen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dullyellow">dullyellow</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dullblue">dullblue</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dullmagenta">dullmagenta</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dullcyan">dullcyan</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:dullwhite">dullwhite</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:onblack">onblack</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:onred">onred</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ongreen">ongreen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:onyellow">onyellow</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:onblue">onblue</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:onmagenta">onmagenta</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:oncyan">oncyan</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:onwhite">onwhite</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ondullblack">ondullblack</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ondullred">ondullred</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ondullgreen">ondullgreen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ondullyellow">ondullyellow</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ondullblue">ondullblue</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ondullmagenta">ondullmagenta</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ondullcyan">ondullcyan</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ondullwhite">ondullwhite</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:bold">bold</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:debold">debold</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:underline">underline</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:deunderline">deunderline</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:plain">plain</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:string">string</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:int">int</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:integer">integer</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Integer">Integer</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:float">float</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Float">Float</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:double">double</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Double">Double</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rational">rational</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Rational">Rational</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><span class="keyword">class</span> <a href="#t:Pretty">Pretty</a> a <span class="keyword">where</span><ul class="subs"><li><a href="#v:pretty">pretty</a> :: a -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li><a href="#v:prettyList">prettyList</a> :: [a] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:SimpleDoc">SimpleDoc</a> <ul class="subs"><li>= <a href="#v:SFail">SFail</a> </li><li>| <a href="#v:SEmpty">SEmpty</a> </li><li>| <a href="#v:SChar">SChar</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Char.html#t:Char">Char</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a> </li><li>| <a href="#v:SText">SText</a> !<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-String.html#t:String">String</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a> </li><li>| <a href="#v:SLine">SLine</a> !<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a> </li><li>| <a href="#v:SSGR">SSGR</a> [<a href="/usr/share/doc/ghc/html/libraries/ansi-terminal-0.5.5.1/System-Console-ANSI.html#t:SGR">SGR</a>] <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a> </li></ul></li><li class="src short"><a href="#v:renderPretty">renderPretty</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Float">Float</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a></li><li class="src short"><a href="#v:renderCompact">renderCompact</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a></li><li class="src short"><a href="#v:displayS">displayS</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Text-Show.html#t:ShowS">ShowS</a></li><li class="src short"><a href="#v:displayIO">displayIO</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/GHC-IO-Handle.html#t:Handle">Handle</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:bool">bool</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:column">column</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>) -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:columns">columns</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>) -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:nesting">nesting</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>) -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:width">width</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>) -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></li></ul></div><div id="interface"><h1 id="g:1">Documents </h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Doc" class="def">Doc</a> <a href="src/Text-PrettyPrint-ANSI-Leijen.html#Doc" class="link">Source</a></p><div class="doc"><p>The abstract data type <code>Doc</code> represents pretty documents. </p><p><code>Doc</code> is an instance of the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Text-Show.html#t:Show">Show</a></code> class. <code>(show doc)</code> pretty prints document <code>doc</code> with a page width of 100 characters and a ribbon width of 40 characters. </p><pre> show (text "hello" <$> text "world") </pre><p>Which would return the string "hello\nworld", i.e. </p><pre> hello world </pre></div><div class="subs instances"><p id="control.i:Doc" class="caption collapser" onclick="toggleSection('i:Doc')">Instances</p><div id="section.i:Doc" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Text-Show.html#t:Show">Show</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-String.html#t:IsString">IsString</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:putDoc" class="def">putDoc</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#putDoc" class="link">Source</a></p><div class="doc"><p>The action <code>(putDoc doc)</code> pretty prints document <code>doc</code> to the standard output, with a page width of 100 characters and a ribbon width of 40 characters. </p><pre> main :: IO () main = do{ putDoc (text "hello" <+> text "world") } </pre><p>Which would output </p><pre> hello world </pre><p>Any ANSI colorisation in <code>doc</code> will be output. </p></div></div><div class="top"><p class="src"><a name="v:hPutDoc" class="def">hPutDoc</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/GHC-IO-Handle.html#t:Handle">Handle</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#hPutDoc" class="link">Source</a></p><div class="doc"><p><code>(hPutDoc handle doc)</code> pretty prints document <code>doc</code> to the file handle <code>handle</code> with a page width of 100 characters and a ribbon width of 40 characters. </p><pre> main = do{ handle <- openFile "MyFile" WriteMode ; hPutDoc handle (vcat (map text ["vertical","text"])) ; hClose handle } </pre><p>Any ANSI colorisation in <code>doc</code> will be output. </p></div></div><h1 id="g:2">Basic combinators </h1><div class="top"><p class="src"><a name="v:empty" class="def">empty</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#empty" class="link">Source</a></p><div class="doc"><p>The empty document is, indeed, empty. Although <code>empty</code> has no content, it does have a 'height' of 1 and behaves exactly like <code>(text "")</code> (and is therefore not a unit of <code><$></code>). </p></div></div><div class="top"><p class="src"><a name="v:char" class="def">char</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#char" class="link">Source</a></p><div class="doc"><p>The document <code>(char c)</code> contains the literal character <code>c</code>. The character shouldn't be a newline (<code>'\n'</code>), the function <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:line">line</a></code> should be used for line breaks. </p></div></div><div class="top"><p class="src"><a name="v:text" class="def">text</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#text" class="link">Source</a></p><div class="doc"><p>The document <code>(text s)</code> contains the literal string <code>s</code>. The string shouldn't contain any newline (<code>'\n'</code>) characters. If the string contains newline characters, the function <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:string">string</a></code> should be used. </p></div></div><div class="top"><p class="src"><a name="v:-60--62-" class="def">(<>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#%3C%3E" class="link">Source</a></p><div class="doc"><p>The document <code>(x <> y)</code> concatenates document <code>x</code> and document <code>y</code>. It is an associative operation having <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:empty">empty</a></code> as a left and right unit. (infixr 6) </p></div></div><div class="top"><p class="src"><a name="v:nest" class="def">nest</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#nest" class="link">Source</a></p><div class="doc"><p>The document <code>(nest i x)</code> renders document <code>x</code> with the current indentation level increased by i (See also <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:hang">hang</a></code>, <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:align">align</a></code> and <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:indent">indent</a></code>). </p><pre> nest 2 (text "hello" <$> text "world") <$> text "!" </pre><p>outputs as: </p><pre> hello world ! </pre></div></div><div class="top"><p class="src"><a name="v:line" class="def">line</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#line" class="link">Source</a></p><div class="doc"><p>The <code>line</code> document advances to the next line and indents to the current nesting level. Document <code>line</code> behaves like <code>(text " ")</code> if the line break is undone by <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:group">group</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:linebreak" class="def">linebreak</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#linebreak" class="link">Source</a></p><div class="doc"><p>The <code>linebreak</code> document advances to the next line and indents to the current nesting level. Document <code>linebreak</code> behaves like <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:empty">empty</a></code> if the line break is undone by <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:group">group</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:group" class="def">group</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#group" class="link">Source</a></p><div class="doc"><p>The <code>group</code> combinator is used to specify alternative layouts. The document <code>(group x)</code> undoes all line breaks in document <code>x</code>. The resulting line is added to the current line if that fits the page. Otherwise, the document <code>x</code> is rendered without any changes. </p></div></div><div class="top"><p class="src"><a name="v:softline" class="def">softline</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#softline" class="link">Source</a></p><div class="doc"><p>The document <code>softline</code> behaves like <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:space">space</a></code> if the resulting output fits the page, otherwise it behaves like <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:line">line</a></code>. </p><pre> softline = group line </pre></div></div><div class="top"><p class="src"><a name="v:softbreak" class="def">softbreak</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#softbreak" class="link">Source</a></p><div class="doc"><p>The document <code>softbreak</code> behaves like <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:empty">empty</a></code> if the resulting output fits the page, otherwise it behaves like <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:line">line</a></code>. </p><pre> softbreak = group linebreak </pre></div></div><div class="top"><p class="src"><a name="v:hardline" class="def">hardline</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#hardline" class="link">Source</a></p><div class="doc"><p>A linebreak that will never be flattened; it is guaranteed to render as a newline. </p></div></div><div class="top"><p class="src"><a name="v:flatAlt" class="def">flatAlt</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#flatAlt" class="link">Source</a></p><div class="doc"><p>A document that is normally rendered as the first argument, but when flattened, is rendered as the second document. </p></div></div><div class="top"><p class="src"><a name="v:renderSmart" class="def">renderSmart</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Float">Float</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#renderSmart" class="link">Source</a></p><div class="doc"><p>A slightly smarter rendering algorithm with more lookahead. It provides provide earlier breaking on deeply nested structures For example, consider this python-ish pseudocode: <code>fun(fun(fun(fun(fun([abcdefg, abcdefg])))))</code> If we put a softbreak (+ nesting 2) after each open parenthesis, and align the elements of the list to match the opening brackets, this will render with <code>renderPretty</code> and a page width of 20 as: <code> fun(fun(fun(fun(fun([ | abcdef, | abcdef, ] ))))) | </code> Where the 20c. boundary has been marked with |. Because <code>renderPretty</code> only uses one-line lookahead, it sees that the first line fits, and is stuck putting the second and third lines after the 20-c mark. In contrast, <code>renderSmart</code> will continue to check that the potential document up to the end of the indentation level. Thus, it will format the document as: </p><p><code> fun( | fun( | fun( | fun( | fun([ | abcdef, abcdef, ] | ))))) | </code> Which fits within the 20c. boundary. </p></div></div><h1 id="g:3">Alignment </h1><div class="top"><p class="src"><a name="v:align" class="def">align</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#align" class="link">Source</a></p><div class="doc"><p>The document <code>(align x)</code> renders document <code>x</code> with the nesting level set to the current column. It is used for example to implement <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:hang">hang</a></code>. </p><p>As an example, we will put a document right above another one, regardless of the current nesting level: </p><pre> x $$ y = align (x <$> y) </pre><pre> test = text "hi" <+> (text "nice" $$ text "world") </pre><p>which will be layed out as: </p><pre> hi nice world </pre></div></div><div class="top"><p class="src"><a name="v:hang" class="def">hang</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#hang" class="link">Source</a></p><div class="doc"><p>The hang combinator implements hanging indentation. The document <code>(hang i x)</code> renders document <code>x</code> with a nesting level set to the current column plus <code>i</code>. The following example uses hanging indentation for some text: </p><pre> test = hang 4 (fillSep (map text (words "the hang combinator indents these words !"))) </pre><p>Which lays out on a page with a width of 20 characters as: </p><pre> the hang combinator indents these words ! </pre><p>The <code>hang</code> combinator is implemented as: </p><pre> hang i x = align (nest i x) </pre></div></div><div class="top"><p class="src"><a name="v:indent" class="def">indent</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#indent" class="link">Source</a></p><div class="doc"><p>The document <code>(indent i x)</code> indents document <code>x</code> with <code>i</code> spaces. </p><pre> test = indent 4 (fillSep (map text (words "the indent combinator indents these words !"))) </pre><p>Which lays out with a page width of 20 as: </p><pre> the indent combinator indents these words ! </pre></div></div><div class="top"><p class="src"><a name="v:encloseSep" class="def">encloseSep</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#encloseSep" class="link">Source</a></p><div class="doc"><p>The document <code>(encloseSep l r sep xs)</code> concatenates the documents <code>xs</code> separated by <code>sep</code> and encloses the resulting document by <code>l</code> and <code>r</code>. The documents are rendered horizontally if that fits the page. Otherwise they are aligned vertically. All separators are put in front of the elements. For example, the combinator <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:list">list</a></code> can be defined with <code>encloseSep</code>: </p><pre> list xs = encloseSep lbracket rbracket comma xs test = text "list" <+> (list (map int [10,200,3000])) </pre><p>Which is layed out with a page width of 20 as: </p><pre> list [10,200,3000] </pre><p>But when the page width is 15, it is layed out as: </p><pre> list [10 ,200 ,3000] </pre></div></div><div class="top"><p class="src"><a name="v:list" class="def">list</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#list" class="link">Source</a></p><div class="doc"><p>The document <code>(list xs)</code> comma separates the documents <code>xs</code> and encloses them in square brackets. The documents are rendered horizontally if that fits the page. Otherwise they are aligned vertically. All comma separators are put in front of the elements. </p></div></div><div class="top"><p class="src"><a name="v:tupled" class="def">tupled</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#tupled" class="link">Source</a></p><div class="doc"><p>The document <code>(tupled xs)</code> comma separates the documents <code>xs</code> and encloses them in parenthesis. The documents are rendered horizontally if that fits the page. Otherwise they are aligned vertically. All comma separators are put in front of the elements. </p></div></div><div class="top"><p class="src"><a name="v:semiBraces" class="def">semiBraces</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#semiBraces" class="link">Source</a></p><div class="doc"><p>The document <code>(semiBraces xs)</code> separates the documents <code>xs</code> with semi colons and encloses them in braces. The documents are rendered horizontally if that fits the page. Otherwise they are aligned vertically. All semi colons are put in front of the elements. </p></div></div><h1 id="g:4">Operators </h1><div class="top"><p class="src"><a name="v:-60--43--62-" class="def">(<+>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#%3C%2B%3E" class="link">Source</a></p><div class="doc"><p>The document <code>(x <+> y)</code> concatenates document <code>x</code> and <code>y</code> with a <code>space</code> in between. (infixr 6) </p></div></div><div class="top"><p class="src"><a name="v:-60--36--62-" class="def">(<$>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#%3C%24%3E" class="link">Source</a></p><div class="doc"><p>The document <code>(x <$> y)</code> concatenates document <code>x</code> and <code>y</code> with a <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:line">line</a></code> in between. (infixr 5) </p></div></div><div class="top"><p class="src"><a name="v:-60--47--62-" class="def">(</>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#%3C%2F%3E" class="link">Source</a></p><div class="doc"><p>The document <code>(x </> y)</code> concatenates document <code>x</code> and <code>y</code> with a <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:softline">softline</a></code> in between. This effectively puts <code>x</code> and <code>y</code> either next to each other (with a <code>space</code> in between) or underneath each other. (infixr 5) </p></div></div><div class="top"><p class="src"><a name="v:-60--36--36--62-" class="def">(<$$>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#%3C%24%24%3E" class="link">Source</a></p><div class="doc"><p>The document <code>(x <$$> y)</code> concatenates document <code>x</code> and <code>y</code> with a <code>linebreak</code> in between. (infixr 5) </p></div></div><div class="top"><p class="src"><a name="v:-60--47--47--62-" class="def">(<//>)</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#%3C%2F%2F%3E" class="link">Source</a></p><div class="doc"><p>The document <code>(x <//> y)</code> concatenates document <code>x</code> and <code>y</code> with a <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:softbreak">softbreak</a></code> in between. This effectively puts <code>x</code> and <code>y</code> either right next to each other or underneath each other. (infixr 5) </p></div></div><h1 id="g:5">List combinators </h1><div class="top"><p class="src"><a name="v:hsep" class="def">hsep</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#hsep" class="link">Source</a></p><div class="doc"><p>The document <code>(hsep xs)</code> concatenates all documents <code>xs</code> horizontally with <code>(<+>)</code>. </p></div></div><div class="top"><p class="src"><a name="v:vsep" class="def">vsep</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#vsep" class="link">Source</a></p><div class="doc"><p>The document <code>(vsep xs)</code> concatenates all documents <code>xs</code> vertically with <code>(<$>)</code>. If a <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:group">group</a></code> undoes the line breaks inserted by <code>vsep</code>, all documents are separated with a space. </p><pre> someText = map text (words ("text to lay out")) test = text "some" <+> vsep someText </pre><p>This is layed out as: </p><pre> some text to lay out </pre><p>The <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:align">align</a></code> combinator can be used to align the documents under their first element </p><pre> test = text "some" <+> align (vsep someText) </pre><p>Which is printed as: </p><pre> some text to lay out </pre></div></div><div class="top"><p class="src"><a name="v:fillSep" class="def">fillSep</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#fillSep" class="link">Source</a></p><div class="doc"><p>The document <code>(fillSep xs)</code> concatenates documents <code>xs</code> horizontally with <code>(<+>)</code> as long as its fits the page, than inserts a <code>line</code> and continues doing that for all documents in <code>xs</code>. </p><pre> fillSep xs = foldr (\<\/\>) empty xs </pre></div></div><div class="top"><p class="src"><a name="v:sep" class="def">sep</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#sep" class="link">Source</a></p><div class="doc"><p>The document <code>(sep xs)</code> concatenates all documents <code>xs</code> either horizontally with <code>(<+>)</code>, if it fits the page, or vertically with <code>(<$>)</code>. </p><pre> sep xs = group (vsep xs) </pre></div></div><div class="top"><p class="src"><a name="v:hcat" class="def">hcat</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#hcat" class="link">Source</a></p><div class="doc"><p>The document <code>(hcat xs)</code> concatenates all documents <code>xs</code> horizontally with <code>(<>)</code>. </p></div></div><div class="top"><p class="src"><a name="v:vcat" class="def">vcat</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#vcat" class="link">Source</a></p><div class="doc"><p>The document <code>(vcat xs)</code> concatenates all documents <code>xs</code> vertically with <code>(<$$>)</code>. If a <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:group">group</a></code> undoes the line breaks inserted by <code>vcat</code>, all documents are directly concatenated. </p></div></div><div class="top"><p class="src"><a name="v:fillCat" class="def">fillCat</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#fillCat" class="link">Source</a></p><div class="doc"><p>The document <code>(fillCat xs)</code> concatenates documents <code>xs</code> horizontally with <code>(<>)</code> as long as its fits the page, than inserts a <code>linebreak</code> and continues doing that for all documents in <code>xs</code>. </p><pre> fillCat xs = foldr (\<\/\/\>) empty xs </pre></div></div><div class="top"><p class="src"><a name="v:cat" class="def">cat</a> :: [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#cat" class="link">Source</a></p><div class="doc"><p>The document <code>(cat xs)</code> concatenates all documents <code>xs</code> either horizontally with <code>(<>)</code>, if it fits the page, or vertically with <code>(<$$>)</code>. </p><pre> cat xs = group (vcat xs) </pre></div></div><div class="top"><p class="src"><a name="v:punctuate" class="def">punctuate</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>] -> [<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>]<a href="src/Text-PrettyPrint-ANSI-Leijen.html#punctuate" class="link">Source</a></p><div class="doc"><p><code>(punctuate p xs)</code> concatenates all documents in <code>xs</code> with document <code>p</code> except for the last document. </p><pre> someText = map text ["words","in","a","tuple"] test = parens (align (cat (punctuate comma someText))) </pre><p>This is layed out on a page width of 20 as: </p><pre> (words,in,a,tuple) </pre><p>But when the page width is 15, it is layed out as: </p><pre> (words, in, a, tuple) </pre><p>(If you want put the commas in front of their elements instead of at the end, you should use <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:tupled">tupled</a></code> or, in general, <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:encloseSep">encloseSep</a></code>.) </p></div></div><h1 id="g:6">Fillers </h1><div class="top"><p class="src"><a name="v:fill" class="def">fill</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#fill" class="link">Source</a></p><div class="doc"><p>The document <code>(fill i x)</code> renders document <code>x</code>. It than appends <code>space</code>s until the width is equal to <code>i</code>. If the width of <code>x</code> is already larger, nothing is appended. This combinator is quite useful in practice to output a list of bindings. The following example demonstrates this. </p><pre> types = [("empty","Doc") ,("nest","Int -> Doc -> Doc") ,("linebreak","Doc")] ptype (name,tp) = fill 6 (text name) <+> text "::" <+> text tp test = text "let" <+> align (vcat (map ptype types)) </pre><p>Which is layed out as: </p><pre> let empty :: Doc nest :: Int -> Doc -> Doc linebreak :: Doc </pre></div></div><div class="top"><p class="src"><a name="v:fillBreak" class="def">fillBreak</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#fillBreak" class="link">Source</a></p><div class="doc"><p>The document <code>(fillBreak i x)</code> first renders document <code>x</code>. It than appends <code>space</code>s until the width is equal to <code>i</code>. If the width of <code>x</code> is already larger than <code>i</code>, the nesting level is increased by <code>i</code> and a <code>line</code> is appended. When we redefine <code>ptype</code> in the previous example to use <code>fillBreak</code>, we get a useful variation of the previous output: </p><pre> ptype (name,tp) = fillBreak 6 (text name) <+> text "::" <+> text tp </pre><p>The output will now be: </p><pre> let empty :: Doc nest :: Int -> Doc -> Doc linebreak :: Doc </pre></div></div><h1 id="g:7">Bracketing combinators </h1><div class="top"><p class="src"><a name="v:enclose" class="def">enclose</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#enclose" class="link">Source</a></p><div class="doc"><p>The document <code>(enclose l r x)</code> encloses document <code>x</code> between documents <code>l</code> and <code>r</code> using <code>(<>)</code>. </p><pre> enclose l r x = l <> x <> r </pre></div></div><div class="top"><p class="src"><a name="v:squotes" class="def">squotes</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#squotes" class="link">Source</a></p><div class="doc"><p>Document <code>(squotes x)</code> encloses document <code>x</code> with single quotes "'". </p></div></div><div class="top"><p class="src"><a name="v:dquotes" class="def">dquotes</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dquotes" class="link">Source</a></p><div class="doc"><p>Document <code>(dquotes x)</code> encloses document <code>x</code> with double quotes '"'. </p></div></div><div class="top"><p class="src"><a name="v:parens" class="def">parens</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#parens" class="link">Source</a></p><div class="doc"><p>Document <code>(parens x)</code> encloses document <code>x</code> in parenthesis, "(" and ")". </p></div></div><div class="top"><p class="src"><a name="v:angles" class="def">angles</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#angles" class="link">Source</a></p><div class="doc"><p>Document <code>(angles x)</code> encloses document <code>x</code> in angles, "<" and ">". </p></div></div><div class="top"><p class="src"><a name="v:braces" class="def">braces</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#braces" class="link">Source</a></p><div class="doc"><p>Document <code>(braces x)</code> encloses document <code>x</code> in braces, "{" and "}". </p></div></div><div class="top"><p class="src"><a name="v:brackets" class="def">brackets</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#brackets" class="link">Source</a></p><div class="doc"><p>Document <code>(brackets x)</code> encloses document <code>x</code> in square brackets, "[" and "]". </p></div></div><h1 id="g:8">Character documents </h1><div class="top"><p class="src"><a name="v:lparen" class="def">lparen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#lparen" class="link">Source</a></p><div class="doc"><p>The document <code>lparen</code> contains a left parenthesis, "(". </p></div></div><div class="top"><p class="src"><a name="v:rparen" class="def">rparen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#rparen" class="link">Source</a></p><div class="doc"><p>The document <code>rparen</code> contains a right parenthesis, ")". </p></div></div><div class="top"><p class="src"><a name="v:langle" class="def">langle</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#langle" class="link">Source</a></p><div class="doc"><p>The document <code>langle</code> contains a left angle, "<". </p></div></div><div class="top"><p class="src"><a name="v:rangle" class="def">rangle</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#rangle" class="link">Source</a></p><div class="doc"><p>The document <code>rangle</code> contains a right angle, ">". </p></div></div><div class="top"><p class="src"><a name="v:lbrace" class="def">lbrace</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#lbrace" class="link">Source</a></p><div class="doc"><p>The document <code>lbrace</code> contains a left brace, "{". </p></div></div><div class="top"><p class="src"><a name="v:rbrace" class="def">rbrace</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#rbrace" class="link">Source</a></p><div class="doc"><p>The document <code>rbrace</code> contains a right brace, "}". </p></div></div><div class="top"><p class="src"><a name="v:lbracket" class="def">lbracket</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#lbracket" class="link">Source</a></p><div class="doc"><p>The document <code>lbracket</code> contains a left square bracket, "[". </p></div></div><div class="top"><p class="src"><a name="v:rbracket" class="def">rbracket</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#rbracket" class="link">Source</a></p><div class="doc"><p>The document <code>rbracket</code> contains a right square bracket, "]". </p></div></div><div class="top"><p class="src"><a name="v:squote" class="def">squote</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#squote" class="link">Source</a></p><div class="doc"><p>The document <code>squote</code> contains a single quote, "'". </p></div></div><div class="top"><p class="src"><a name="v:dquote" class="def">dquote</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dquote" class="link">Source</a></p><div class="doc"><p>The document <code>dquote</code> contains a double quote, '"'. </p></div></div><div class="top"><p class="src"><a name="v:semi" class="def">semi</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#semi" class="link">Source</a></p><div class="doc"><p>The document <code>semi</code> contains a semi colon, ";". </p></div></div><div class="top"><p class="src"><a name="v:colon" class="def">colon</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#colon" class="link">Source</a></p><div class="doc"><p>The document <code>colon</code> contains a colon, ":". </p></div></div><div class="top"><p class="src"><a name="v:comma" class="def">comma</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#comma" class="link">Source</a></p><div class="doc"><p>The document <code>comma</code> contains a comma, ",". </p></div></div><div class="top"><p class="src"><a name="v:space" class="def">space</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#space" class="link">Source</a></p><div class="doc"><p>The document <code>space</code> contains a single space, " ". </p><pre> x <+> y = x <> space <> y </pre></div></div><div class="top"><p class="src"><a name="v:dot" class="def">dot</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dot" class="link">Source</a></p><div class="doc"><p>The document <code>dot</code> contains a single dot, ".". </p></div></div><div class="top"><p class="src"><a name="v:backslash" class="def">backslash</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#backslash" class="link">Source</a></p><div class="doc"><p>The document <code>backslash</code> contains a back slash, "\". </p></div></div><div class="top"><p class="src"><a name="v:equals" class="def">equals</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#equals" class="link">Source</a></p><div class="doc"><p>The document <code>equals</code> contains an equal sign, "=". </p></div></div><h1 id="g:9">Colorisation combinators </h1><div class="top"><p class="src"><a name="v:black" class="def">black</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#black" class="link">Source</a></p><div class="doc"><p>Displays a document with the black forecolor </p></div></div><div class="top"><p class="src"><a name="v:red" class="def">red</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#red" class="link">Source</a></p><div class="doc"><p>Displays a document with the red forecolor </p></div></div><div class="top"><p class="src"><a name="v:green" class="def">green</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#green" class="link">Source</a></p><div class="doc"><p>Displays a document with the green forecolor </p></div></div><div class="top"><p class="src"><a name="v:yellow" class="def">yellow</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#yellow" class="link">Source</a></p><div class="doc"><p>Displays a document with the yellow forecolor </p></div></div><div class="top"><p class="src"><a name="v:blue" class="def">blue</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#blue" class="link">Source</a></p><div class="doc"><p>Displays a document with the blue forecolor </p></div></div><div class="top"><p class="src"><a name="v:magenta" class="def">magenta</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#magenta" class="link">Source</a></p><div class="doc"><p>Displays a document with the magenta forecolor </p></div></div><div class="top"><p class="src"><a name="v:cyan" class="def">cyan</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#cyan" class="link">Source</a></p><div class="doc"><p>Displays a document with the cyan forecolor </p></div></div><div class="top"><p class="src"><a name="v:white" class="def">white</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#white" class="link">Source</a></p><div class="doc"><p>Displays a document with the white forecolor </p></div></div><div class="top"><p class="src"><a name="v:dullblack" class="def">dullblack</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dullblack" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull black forecolor </p></div></div><div class="top"><p class="src"><a name="v:dullred" class="def">dullred</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dullred" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull red forecolor </p></div></div><div class="top"><p class="src"><a name="v:dullgreen" class="def">dullgreen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dullgreen" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull green forecolor </p></div></div><div class="top"><p class="src"><a name="v:dullyellow" class="def">dullyellow</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dullyellow" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull yellow forecolor </p></div></div><div class="top"><p class="src"><a name="v:dullblue" class="def">dullblue</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dullblue" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull blue forecolor </p></div></div><div class="top"><p class="src"><a name="v:dullmagenta" class="def">dullmagenta</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dullmagenta" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull magenta forecolor </p></div></div><div class="top"><p class="src"><a name="v:dullcyan" class="def">dullcyan</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dullcyan" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull cyan forecolor </p></div></div><div class="top"><p class="src"><a name="v:dullwhite" class="def">dullwhite</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#dullwhite" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull white forecolor </p></div></div><div class="top"><p class="src"><a name="v:onblack" class="def">onblack</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#onblack" class="link">Source</a></p><div class="doc"><p>Displays a document with the black backcolor </p></div></div><div class="top"><p class="src"><a name="v:onred" class="def">onred</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#onred" class="link">Source</a></p><div class="doc"><p>Displays a document with the red backcolor </p></div></div><div class="top"><p class="src"><a name="v:ongreen" class="def">ongreen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ongreen" class="link">Source</a></p><div class="doc"><p>Displays a document with the green backcolor </p></div></div><div class="top"><p class="src"><a name="v:onyellow" class="def">onyellow</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#onyellow" class="link">Source</a></p><div class="doc"><p>Displays a document with the yellow backcolor </p></div></div><div class="top"><p class="src"><a name="v:onblue" class="def">onblue</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#onblue" class="link">Source</a></p><div class="doc"><p>Displays a document with the blue backcolor </p></div></div><div class="top"><p class="src"><a name="v:onmagenta" class="def">onmagenta</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#onmagenta" class="link">Source</a></p><div class="doc"><p>Displays a document with the magenta backcolor </p></div></div><div class="top"><p class="src"><a name="v:oncyan" class="def">oncyan</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#oncyan" class="link">Source</a></p><div class="doc"><p>Displays a document with the cyan backcolor </p></div></div><div class="top"><p class="src"><a name="v:onwhite" class="def">onwhite</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#onwhite" class="link">Source</a></p><div class="doc"><p>Displays a document with the white backcolor </p></div></div><div class="top"><p class="src"><a name="v:ondullblack" class="def">ondullblack</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ondullblack" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull block backcolor </p></div></div><div class="top"><p class="src"><a name="v:ondullred" class="def">ondullred</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ondullred" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull red backcolor </p></div></div><div class="top"><p class="src"><a name="v:ondullgreen" class="def">ondullgreen</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ondullgreen" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull green backcolor </p></div></div><div class="top"><p class="src"><a name="v:ondullyellow" class="def">ondullyellow</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ondullyellow" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull yellow backcolor </p></div></div><div class="top"><p class="src"><a name="v:ondullblue" class="def">ondullblue</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ondullblue" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull blue backcolor </p></div></div><div class="top"><p class="src"><a name="v:ondullmagenta" class="def">ondullmagenta</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ondullmagenta" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull magenta backcolor </p></div></div><div class="top"><p class="src"><a name="v:ondullcyan" class="def">ondullcyan</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ondullcyan" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull cyan backcolor </p></div></div><div class="top"><p class="src"><a name="v:ondullwhite" class="def">ondullwhite</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#ondullwhite" class="link">Source</a></p><div class="doc"><p>Displays a document with the dull white backcolor </p></div></div><h1 id="g:10">Emboldening combinators </h1><div class="top"><p class="src"><a name="v:bold" class="def">bold</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#bold" class="link">Source</a></p><div class="doc"><p>Displays a document in a heavier font weight </p></div></div><div class="top"><p class="src"><a name="v:debold" class="def">debold</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#debold" class="link">Source</a></p><div class="doc"><p>Displays a document in the normal font weight </p></div></div><h1 id="g:11">Underlining combinators </h1><div class="top"><p class="src"><a name="v:underline" class="def">underline</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#underline" class="link">Source</a></p><div class="doc"><p>Displays a document with underlining </p></div></div><div class="top"><p class="src"><a name="v:deunderline" class="def">deunderline</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#deunderline" class="link">Source</a></p><div class="doc"><p>Displays a document with no underlining </p></div></div><h1 id="g:12">Removing formatting </h1><div class="top"><p class="src"><a name="v:plain" class="def">plain</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#plain" class="link">Source</a></p><div class="doc"><p>Removes all colorisation, emboldening and underlining from a document </p></div></div><h1 id="g:13">Primitive type documents </h1><div class="top"><p class="src"><a name="v:string" class="def">string</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#string" class="link">Source</a></p><div class="doc"><p>The document <code>(string s)</code> concatenates all characters in <code>s</code> using <code>line</code> for newline characters and <code>char</code> for all other characters. It is used instead of <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:text">text</a></code> whenever the text contains newline characters. </p></div></div><div class="top"><p class="src"><a name="v:int" class="def">int</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#int" class="link">Source</a></p><div class="doc"><p>The document <code>(int i)</code> shows the literal integer <code>i</code> using <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:text">text</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:integer" class="def">integer</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Integer">Integer</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#integer" class="link">Source</a></p><div class="doc"><p>The document <code>(integer i)</code> shows the literal integer <code>i</code> using <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:text">text</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:float" class="def">float</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Float">Float</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#float" class="link">Source</a></p><div class="doc"><p>The document <code>(float f)</code> shows the literal float <code>f</code> using <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:text">text</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:double" class="def">double</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Double">Double</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#double" class="link">Source</a></p><div class="doc"><p>The document <code>(double d)</code> shows the literal double <code>d</code> using <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:text">text</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:rational" class="def">rational</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Rational">Rational</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#rational" class="link">Source</a></p><div class="doc"><p>The document <code>(rational r)</code> shows the literal rational <code>r</code> using <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:text">text</a></code>. </p></div></div><h1 id="g:14">Pretty class </h1><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:Pretty" class="def">Pretty</a> a <span class="keyword">where</span><a href="src/Text-PrettyPrint-ANSI-Leijen.html#Pretty" class="link">Source</a></p><div class="doc"><p>The member <code>prettyList</code> is only used to define the <code>instance Pretty a => Pretty [a]</code>. In normal circumstances only the <code>pretty</code> function is used. </p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:pretty" class="def">pretty</a> :: a -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#pretty" class="link">Source</a></p><p class="src"><a name="v:prettyList" class="def">prettyList</a> :: [a] -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#prettyList" class="link">Source</a></p></div><div class="subs instances"><p id="control.i:Pretty" class="caption collapser" onclick="toggleSection('i:Pretty')">Instances</p><div id="section.i:Pretty" class="show"><table><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Char.html#t:Char">Char</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Double">Double</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Float">Float</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Integer">Integer</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> ()</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> a => <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> [a]</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> a => <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">(<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> a, <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> b) => <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> (a, b)</td><td class="doc empty"> </td></tr><tr><td class="src">(<a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> a, <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> b, <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> c) => <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Pretty">Pretty</a> (a, b, c)</td><td class="doc empty"> </td></tr></table></div></div></div><h1 id="g:15">Rendering </h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:SimpleDoc" class="def">SimpleDoc</a> <a href="src/Text-PrettyPrint-ANSI-Leijen.html#SimpleDoc" class="link">Source</a></p><div class="doc"><p>The data type <code>SimpleDoc</code> represents rendered documents and is used by the display functions. </p><p>The <code>Int</code> in <code>SText</code> contains the length of the string. The <code>Int</code> in <code>SLine</code> contains the indentation for that line. The library provides two default display functions <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:displayS">displayS</a></code> and <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:displayIO">displayIO</a></code>. You can provide your own display function by writing a function from a <code>SimpleDoc</code> to your own output format. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:SFail" class="def">SFail</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:SEmpty" class="def">SEmpty</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:SChar" class="def">SChar</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Char.html#t:Char">Char</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:SText" class="def">SText</a> !<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-String.html#t:String">String</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:SLine" class="def">SLine</a> !<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:SSGR" class="def">SSGR</a> [<a href="/usr/share/doc/ghc/html/libraries/ansi-terminal-0.5.5.1/System-Console-ANSI.html#t:SGR">SGR</a>] <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a></td><td class="doc empty"> </td></tr></table></div></div><div class="top"><p class="src"><a name="v:renderPretty" class="def">renderPretty</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Prelude.html#t:Float">Float</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#renderPretty" class="link">Source</a></p><div class="doc"><p>This is the default pretty printer which is used by <code><a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Text-Show.html#v:show">show</a></code>, <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:putDoc">putDoc</a></code> and <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:hPutDoc">hPutDoc</a></code>. <code>(renderPretty ribbonfrac width x)</code> renders document <code>x</code> with a page width of <code>width</code> and a ribbon width of <code>(ribbonfrac * width)</code> characters. The ribbon width is the maximal amount of non-indentation characters on a line. The parameter <code>ribbonfrac</code> should be between <code>0.0</code> and <code>1.0</code>. If it is lower or higher, the ribbon width will be 0 or <code>width</code> respectively. </p></div></div><div class="top"><p class="src"><a name="v:renderCompact" class="def">renderCompact</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#renderCompact" class="link">Source</a></p><div class="doc"><p><code>(renderCompact x)</code> renders document <code>x</code> without adding any indentation. Since no 'pretty' printing is involved, this renderer is very fast. The resulting output contains fewer characters than a pretty printed version and can be used for output that is read by other programs. </p><p>This rendering function does not add any colorisation information. </p></div></div><div class="top"><p class="src"><a name="v:displayS" class="def">displayS</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Text-Show.html#t:ShowS">ShowS</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#displayS" class="link">Source</a></p><div class="doc"><p><code>(displayS simpleDoc)</code> takes the output <code>simpleDoc</code> from a rendering function and transforms it to a <code><a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Text-Show.html#t:ShowS">ShowS</a></code> type (for use in the <code><a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Text-Show.html#t:Show">Show</a></code> class). </p><pre> showWidth :: Int -> Doc -> String showWidth w x = displayS (renderPretty 0.4 w x) "" </pre><p>ANSI color information will be discarded by this function unless you are running on a Unix-like operating system. This is due to a technical limitation in Windows ANSI support. </p></div></div><div class="top"><p class="src"><a name="v:displayIO" class="def">displayIO</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/GHC-IO-Handle.html#t:Handle">Handle</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:SimpleDoc">SimpleDoc</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#displayIO" class="link">Source</a></p><div class="doc"><p><code>(displayIO handle simpleDoc)</code> writes <code>simpleDoc</code> to the file handle <code>handle</code>. This function is used for example by <code><a href="Text-PrettyPrint-ANSI-Leijen.html#v:hPutDoc">hPutDoc</a></code>: </p><pre> hPutDoc handle doc = displayIO handle (renderPretty 0.4 100 doc) </pre><p>Any ANSI colorisation in <code>simpleDoc</code> will be output. </p></div></div><h1 id="g:16">Undocumented </h1><div class="top"><p class="src"><a name="v:bool" class="def">bool</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#bool" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:column" class="def">column</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>) -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#column" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:columns" class="def">columns</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>) -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#columns" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:nesting" class="def">nesting</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>) -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#nesting" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:width" class="def">width</a> :: <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a> -> (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a>) -> <a href="Text-PrettyPrint-ANSI-Leijen.html#t:Doc">Doc</a><a href="src/Text-PrettyPrint-ANSI-Leijen.html#width" class="link">Source</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>