<!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</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.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">pretty-1.1.1.0: Pretty-printing library</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>stable</td></tr><tr><th>Maintainer</th><td>David Terei <dave.terei@gmail.com></td></tr><tr><th>Safe Haskell</th><td>Safe</td></tr></table><p class="caption">Text.PrettyPrint</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">The document type </a></li><li><a href="#g:2">Constructing documents </a><ul><li><a href="#g:3">Converting values into documents </a></li><li><a href="#g:4">Simple derived documents </a></li><li><a href="#g:5">Wrapping documents in delimiters </a></li><li><a href="#g:6">Combining documents </a></li></ul></li><li><a href="#g:7">Predicates on documents </a></li><li><a href="#g:8">Rendering documents </a><ul><li><a href="#g:9">Default rendering </a></li><li><a href="#g:10">Rendering with a particular style </a></li><li><a href="#g:11">General rendering </a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>The default interface to the pretty-printing library. Provides a collection of pretty printer combinators. </p><p>This module should be used as opposed to the <a href="Text-PrettyPrint-HughesPJ.html">Text.PrettyPrint.HughesPJ</a> module. Both are equivalent though as this module simply re-exports the other. </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:char">char</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:text">text</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:ptext">ptext</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:sizedText">sizedText</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:zeroWidthText">zeroWidthText</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:int">int</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:integer">integer</a> :: <a href="../base-4.5.1.0/Prelude.html#t:Integer">Integer</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:float">float</a> :: <a href="../base-4.5.1.0/Prelude.html#t:Float">Float</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:double">double</a> :: <a href="../base-4.5.1.0/Prelude.html#t:Double">Double</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rational">rational</a> :: <a href="../base-4.5.1.0/Prelude.html#t:Rational">Rational</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:semi">semi</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:comma">comma</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:colon">colon</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:space">space</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:equals">equals</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:lparen">lparen</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rparen">rparen</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:lbrack">lbrack</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rbrack">rbrack</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:lbrace">lbrace</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:rbrace">rbrace</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:parens">parens</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:brackets">brackets</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:braces">braces</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:quotes">quotes</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:doubleQuotes">doubleQuotes</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:empty">empty</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-60--62-">(<>)</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-60--43--62-">(<+>)</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:hcat">hcat</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:hsep">hsep</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-36--36-">($$)</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:-36--43--36-">($+$)</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:vcat">vcat</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:sep">sep</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:cat">cat</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:fsep">fsep</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:fcat">fcat</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:nest">nest</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:hang">hang</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></li><li class="src short"><a href="#v:punctuate">punctuate</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>]</li><li class="src short"><a href="#v:isEmpty">isEmpty</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:render">render</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Style">Style</a> = <a href="#v:Style">Style</a> {<ul class="subs"><li><a href="#v:mode">mode</a> :: <a href="Text-PrettyPrint.html#t:Mode">Mode</a></li><li><a href="#v:lineLength">lineLength</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:ribbonsPerLine">ribbonsPerLine</a> :: <a href="../base-4.5.1.0/Prelude.html#t:Float">Float</a></li></ul>}</li><li class="src short"><a href="#v:style">style</a> :: <a href="Text-PrettyPrint.html#t:Style">Style</a></li><li class="src short"><a href="#v:renderStyle">renderStyle</a> :: <a href="Text-PrettyPrint.html#t:Style">Style</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></li><li class="src short"><a href="#v:fullRender">fullRender</a> :: <a href="Text-PrettyPrint.html#t:Mode">Mode</a> -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="../base-4.5.1.0/Prelude.html#t:Float">Float</a> -> (<a href="Text-PrettyPrint.html#t:TextDetails">TextDetails</a> -> a -> a) -> a -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> a</li><li class="src short"><span class="keyword">data</span> <a href="#t:Mode">Mode</a> <ul class="subs"><li>= <a href="#v:PageMode">PageMode</a> </li><li>| <a href="#v:ZigZagMode">ZigZagMode</a> </li><li>| <a href="#v:LeftMode">LeftMode</a> </li><li>| <a href="#v:OneLineMode">OneLineMode</a> </li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:TextDetails">TextDetails</a> <ul class="subs"><li>= <a href="#v:Chr">Chr</a> !<a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> </li><li>| <a href="#v:Str">Str</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> </li><li>| <a href="#v:PStr">PStr</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> </li></ul></li></ul></div><div id="interface"><h1 id="g:1">The document type </h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Doc" class="def">Doc</a> </p><div class="doc"><p>The abstract type of documents. A Doc represents a *set* of layouts. A Doc with no occurrences of Union or NoDoc represents just one layout. </p></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="../base-4.5.1.0/Text-Show.html#t:Show">Show</a> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-String.html#t:IsString">IsString</a> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Monoid.html#t:Monoid">Monoid</a> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr></table></div></div></div><h1 id="g:2">Constructing documents </h1><h2 id="g:3">Converting values into documents </h2><div class="top"><p class="src"><a name="v:char" class="def">char</a> :: <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>A document of height and width 1, containing a literal character. </p></div></div><div class="top"><p class="src"><a name="v:text" class="def">text</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>A document of height 1 containing a literal string. <code><a href="Text-PrettyPrint.html#v:text">text</a></code> satisfies the following laws: </p><ul><li><pre><code><a href="Text-PrettyPrint.html#v:text">text</a></code> s <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> <code><a href="Text-PrettyPrint.html#v:text">text</a></code> t = <code><a href="Text-PrettyPrint.html#v:text">text</a></code> (s<code><a href="../base-4.5.1.0/Data-List.html#v:-43--43-">++</a></code>t)</pre></li><li> <code><code><a href="Text-PrettyPrint.html#v:text">text</a></code> "" <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> x = x</code>, if <code>x</code> non-empty </li></ul><p>The side condition on the last law is necessary because <code><code><a href="Text-PrettyPrint.html#v:text">text</a></code> ""</code> has height 1, while <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code> has no height. </p></div></div><div class="top"><p class="src"><a name="v:ptext" class="def">ptext</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Same as <code>text</code>. Used to be used for Bytestrings. </p></div></div><div class="top"><p class="src"><a name="v:sizedText" class="def">sizedText</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Some text with any width. (<code>text s = sizedText (length s) s</code>) </p></div></div><div class="top"><p class="src"><a name="v:zeroWidthText" class="def">zeroWidthText</a> :: <a href="../base-4.5.1.0/Data-String.html#t:String">String</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Some text, but without any width. Use for non-printing text such as a HTML or Latex tags </p></div></div><div class="top"><p class="src"><a name="v:int" class="def">int</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="../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.html#t:Doc">Doc</a></td><td class="doc"><pre>int n = text (show n)</pre></td></tr></table></div></div><div class="top"><p class="src"><a name="v:integer" class="def">integer</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="../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.html#t:Doc">Doc</a></td><td class="doc"><pre>integer n = text (show n)</pre></td></tr></table></div></div><div class="top"><p class="src"><a name="v:float" class="def">float</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="../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.html#t:Doc">Doc</a></td><td class="doc"><pre>float n = text (show n)</pre></td></tr></table></div></div><div class="top"><p class="src"><a name="v:double" class="def">double</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="../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.html#t:Doc">Doc</a></td><td class="doc"><pre>double n = text (show n)</pre></td></tr></table></div></div><div class="top"><p class="src"><a name="v:rational" class="def">rational</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="../base-4.5.1.0/Prelude.html#t:Rational">Rational</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><pre>rational n = text (show n)</pre></td></tr></table></div></div><h2 id="g:4">Simple derived documents </h2><div class="top"><p class="src"><a name="v:semi" class="def">semi</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A ';' character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:comma" class="def">comma</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A ',' character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:colon" class="def">colon</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A <code>:</code> character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:space" class="def">space</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A space character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:equals" class="def">equals</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A '=' character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:lparen" class="def">lparen</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A '(' character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:rparen" class="def">rparen</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A ')' character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:lbrack" class="def">lbrack</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A '[' character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:rbrack" class="def">rbrack</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A ']' character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:lbrace" class="def">lbrace</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A '{' character </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:rbrace" class="def">rbrace</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>A '}' character </p></td></tr></table></div></div><h2 id="g:5">Wrapping documents in delimiters </h2><div class="top"><p class="src"><a name="v:parens" class="def">parens</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>Wrap document in <code>(...)</code> </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:brackets" class="def">brackets</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>Wrap document in <code>[...]</code> </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:braces" class="def">braces</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>Wrap document in <code>{...}</code> </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:quotes" class="def">quotes</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>Wrap document in <code>'...'</code> </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:doubleQuotes" class="def">doubleQuotes</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>Wrap document in <code>"..."</code> </p></td></tr></table></div></div><h2 id="g:6">Combining documents </h2><div class="top"><p class="src"><a name="v:empty" class="def">empty</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>The empty document, with no height and no width. <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code> is the identity for <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code>, <code><a href="Text-PrettyPrint.html#v:-60--43--62-"><+></a></code>, <code><a href="Text-PrettyPrint.html#v:-36--36-">$$</a></code> and <code><a href="Text-PrettyPrint.html#v:-36--43--36-">$+$</a></code>, and anywhere in the argument list for <code><a href="Text-PrettyPrint.html#v:sep">sep</a></code>, <code><a href="Text-PrettyPrint.html#v:hcat">hcat</a></code>, <code><a href="Text-PrettyPrint.html#v:hsep">hsep</a></code>, <code><a href="Text-PrettyPrint.html#v:vcat">vcat</a></code>, <code><a href="Text-PrettyPrint.html#v:fcat">fcat</a></code> etc. </p></div></div><div class="top"><p class="src"><a name="v:-60--62-" class="def">(<>)</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Beside. <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> is associative, with identity <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:-60--43--62-" class="def">(<+>)</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Beside, separated by space, unless one of the arguments is <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code>. <code><a href="Text-PrettyPrint.html#v:-60--43--62-"><+></a></code> is associative, with identity <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:hcat" class="def">hcat</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>List version of <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code>. </p></div></div><div class="top"><p class="src"><a name="v:hsep" class="def">hsep</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>List version of <code><a href="Text-PrettyPrint.html#v:-60--43--62-"><+></a></code>. </p></div></div><div class="top"><p class="src"><a name="v:-36--36-" class="def">($$)</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Above, except that if the last line of the first argument stops at least one position before the first line of the second begins, these two lines are overlapped. For example: </p><pre> text "hi" $$ nest 5 (text "there") </pre><p>lays out as </p><pre> hi there </pre><p>rather than </p><pre> hi there </pre><p><code><a href="Text-PrettyPrint.html#v:-36--36-">$$</a></code> is associative, with identity <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code>, and also satisfies </p><ul><li> <code>(x <code><a href="Text-PrettyPrint.html#v:-36--36-">$$</a></code> y) <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> z = x <code><a href="Text-PrettyPrint.html#v:-36--36-">$$</a></code> (y <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> z)</code>, if <code>y</code> non-empty. </li></ul></div></div><div class="top"><p class="src"><a name="v:-36--43--36-" class="def">($+$)</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Above, with no overlapping. <code><a href="Text-PrettyPrint.html#v:-36--43--36-">$+$</a></code> is associative, with identity <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:vcat" class="def">vcat</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>List version of <code><a href="Text-PrettyPrint.html#v:-36--36-">$$</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:sep" class="def">sep</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Either <code><a href="Text-PrettyPrint.html#v:hsep">hsep</a></code> or <code><a href="Text-PrettyPrint.html#v:vcat">vcat</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:cat" class="def">cat</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Either <code><a href="Text-PrettyPrint.html#v:hcat">hcat</a></code> or <code><a href="Text-PrettyPrint.html#v:vcat">vcat</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:fsep" class="def">fsep</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>"Paragraph fill" version of <code><a href="Text-PrettyPrint.html#v:sep">sep</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:fcat" class="def">fcat</a> :: [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>"Paragraph fill" version of <code><a href="Text-PrettyPrint.html#v:cat">cat</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:nest" class="def">nest</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><p>Nest (or indent) a document by a given number of positions (which may also be negative). <code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> satisfies the laws: </p><ul><li><pre><code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> 0 x = x</pre></li><li><pre><code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k (<code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k' x) = <code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> (k+k') x</pre></li><li><pre><code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k (x <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> y) = <code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k z <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> <code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k y</pre></li><li><pre><code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k (x <code><a href="Text-PrettyPrint.html#v:-36--36-">$$</a></code> y) = <code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k x <code><a href="Text-PrettyPrint.html#v:-36--36-">$$</a></code> <code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k y</pre></li><li><pre><code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code> = <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code></pre></li><li> <code>x <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> <code><a href="Text-PrettyPrint.html#v:nest">nest</a></code> k y = x <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code> y</code>, if <code>x</code> non-empty </li></ul><p>The side condition on the last law is needed because <code><a href="Text-PrettyPrint.html#v:empty">empty</a></code> is a left identity for <code><a href="Text-PrettyPrint.html#v:-60--62-"><></a></code>. </p></div></div><div class="top"><p class="src"><a name="v:hang" class="def">hang</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></p><div class="doc"><pre>hang d1 n d2 = sep [d1, nest n d2]</pre></div></div><div class="top"><p class="src"><a name="v:punctuate" class="def">punctuate</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>] -> [<a href="Text-PrettyPrint.html#t:Doc">Doc</a>]</p><div class="doc"><pre>punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn]</pre></div></div><h1 id="g:7">Predicates on documents </h1><div class="top"><p class="src"><a name="v:isEmpty" class="def">isEmpty</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>Returns <code><a href="../base-4.5.1.0/Data-Bool.html#v:True">True</a></code> if the document is empty </p></div></div><h1 id="g:8">Rendering documents </h1><h2 id="g:9">Default rendering </h2><div class="top"><p class="src"><a name="v:render" class="def">render</a> :: <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p><div class="doc"><p>Render the <code>Doc</code> to a String using the default <code>Style</code>. </p></div></div><h2 id="g:10">Rendering with a particular style </h2><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Style" class="def">Style</a> </p><div class="doc"><p>A rendering style. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Style" class="def">Style</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:mode" class="def">mode</a> :: <a href="Text-PrettyPrint.html#t:Mode">Mode</a></dt><dd class="doc"><p>The rendering mode </p></dd><dt class="src"><a name="v:lineLength" class="def">lineLength</a> :: <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc"><p>Length of line, in chars </p></dd><dt class="src"><a name="v:ribbonsPerLine" class="def">ribbonsPerLine</a> :: <a href="../base-4.5.1.0/Prelude.html#t:Float">Float</a></dt><dd class="doc"><p>Ratio of ribbon length to line length </p></dd></dl><div class="clear"></div></div></td></tr></table></div></div><div class="top"><p class="src"><a name="v:style" class="def">style</a> :: <a href="Text-PrettyPrint.html#t:Style">Style</a></p><div class="doc"><p>The default style (<code>mode=PageMode, lineLength=100, ribbonsPerLine=1.5</code>). </p></div></div><div class="top"><p class="src"><a name="v:renderStyle" class="def">renderStyle</a> :: <a href="Text-PrettyPrint.html#t:Style">Style</a> -> <a href="Text-PrettyPrint.html#t:Doc">Doc</a> -> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></p><div class="doc"><p>Render the <code>Doc</code> to a String using the given <code>Style</code>. </p></div></div><h2 id="g:11">General rendering </h2><div class="top"><p class="src"><a name="v:fullRender" class="def">fullRender</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Text-PrettyPrint.html#t:Mode">Mode</a></td><td class="doc"><p>Rendering mode </p></td></tr><tr><td class="src">-> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></td><td class="doc"><p>Line length </p></td></tr><tr><td class="src">-> <a href="../base-4.5.1.0/Prelude.html#t:Float">Float</a></td><td class="doc"><p>Ribbons per line </p></td></tr><tr><td class="src">-> (<a href="Text-PrettyPrint.html#t:TextDetails">TextDetails</a> -> a -> a)</td><td class="doc"><p>What to do with text </p></td></tr><tr><td class="src">-> a</td><td class="doc"><p>What to do at the end </p></td></tr><tr><td class="src">-> <a href="Text-PrettyPrint.html#t:Doc">Doc</a></td><td class="doc"><p>The document </p></td></tr><tr><td class="src">-> a</td><td class="doc"><p>Result </p></td></tr></table></div><div class="doc"><p>The general rendering interface. </p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Mode" class="def">Mode</a> </p><div class="doc"><p>Rendering mode. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:PageMode" class="def">PageMode</a></td><td class="doc"><p>Normal </p></td></tr><tr><td class="src"><a name="v:ZigZagMode" class="def">ZigZagMode</a></td><td class="doc"><p>With zig-zag cuts </p></td></tr><tr><td class="src"><a name="v:LeftMode" class="def">LeftMode</a></td><td class="doc"><p>No indentation, infinitely long lines </p></td></tr><tr><td class="src"><a name="v:OneLineMode" class="def">OneLineMode</a></td><td class="doc"><p>All on one line </p></td></tr></table></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:TextDetails" class="def">TextDetails</a> </p><div class="doc"><p>The TextDetails data type </p><p>A TextDetails represents a fragment of text that will be output at some point. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Chr" class="def">Chr</a> !<a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a></td><td class="doc"><p>A single Char fragment </p></td></tr><tr><td class="src"><a name="v:Str" class="def">Str</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></td><td class="doc"><p>A whole String fragment </p></td></tr><tr><td class="src"><a name="v:PStr" class="def">PStr</a> <a href="../base-4.5.1.0/Data-String.html#t:String">String</a></td><td class="doc"><p>Used to represent a Fast String fragment but now deprecated and identical to the Str constructor. </p></td></tr></table></div></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>