HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduledoclayout-0.6Haskell2010

Text.DocLayout

A prettyprinting library for the production of text documents, including wrapped text, indentation and other prefixes, and blocks for tables.

  • 3 types
  • 1 class
  • 66 values
  • Packagedoclayout-0.6
  • Exports70
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceDocLayout.hs

Rendering

3 declarations
valuerenderPlain :: HasChars a => Maybe Int -> Doc a -> a
#

Render a Doc without using ANSI escapes. renderPlain (Just n) will use a line length of n to reflow text on breakable spaces. renderPlain Nothing will not reflow text.

valuerenderANSI :: HasChars a => Maybe Int -> Doc a -> Text
#

Render a Doc with ANSI escapes. renderANSI (Just n) will use a line length of n to reflow text on breakable spaces. renderANSI Nothing will not reflow text.

Doc constructors

43 declarations
valuecr :: Doc a
#

A carriage return. Does nothing if we're at the beginning of a line; otherwise inserts a newline.

valueblankline :: Doc a
#

Inserts a blank line unless one exists already. (blankline <> blankline has the same effect as blankline.

valueblanklines :: Int -> Doc a
#

Inserts blank lines unless they exist already. (blanklines m <> blanklines n has the same effect as blanklines (max m n).

valuespace :: Doc a
#

A breaking (reflowable) space.

valueprefixed :: IsString a => String -> Doc a -> Doc a
#

Uses the specified string as a prefix for every line of the inside document (except the first, if not at the beginning of the line).

valueflush :: Doc a -> Doc a
#

Makes a Doc flush against the left margin.

valuehang :: IsString a => Int -> Doc a -> Doc a -> Doc a
#

A hanging indent. hang ind start doc prints start, then doc, leaving an indent of ind spaces on every line but the first.

valuebeforeNonBlank :: Doc a -> Doc a
#

beforeNonBlank d conditionally includes d unless it is followed by blank space.

valueafterBreak :: Text -> Doc a
#

Content to print only if it comes at the beginning of a line, to be used e.g. for escaping line-initial . in roff man.

valuelblock :: HasChars a => Int -> Doc a -> Doc a
#

lblock n d is a block of width n characters, with text derived from d and aligned to the left.

valuevfill :: HasChars a => a -> Doc a
#

An expandable border that, when placed next to a box, expands to the height of the box. Strings cycle through the list provided.

valuechomp :: Doc a -> Doc a
#

Chomps trailing blank space off of a Doc.

Functions for concatenating documents

7 declarations
value(<+>) :: Doc a -> Doc a -> Doc a
#

Concatenate a list of Docs, putting breakable spaces between them.

value($$) :: Doc a -> Doc a -> Doc a
#

a $$ b puts a above b.

value($+$) :: Doc a -> Doc a -> Doc a
#

a $+$ b puts a above b, with a blank line between.

valuehcat :: [Doc a] -> Doc a
#

Concatenate documents horizontally.

valuehsep :: [Doc a] -> Doc a
#

Same as hcat, but putting breakable spaces between the Docs.

Functions for querying documents

11 declarations
valueupdateColumn :: HasChars a => Doc a -> Int -> Int
#

Returns the column that would be occupied by the last laid out character (assuming no wrapping).

valuecharWidth :: Char -> Int
#

Returns width of a character in a monospace font: 0 for a combining character, 1 for a regular character, 2 for an East Asian wide character. Ambiguous characters are treated as width 1.

valuerealLength :: HasChars a => a -> Int
#

Get real length of string, taking into account combining and double-wide characters. Ambiguous characters are treated as width 1.

valuerealLengthNarrowContext :: HasChars a => a -> Int
#

Get the real length of a string, taking into account combining and double-wide characters. Ambiguous characters are treated as width 1.

valuerealLengthWideContext :: HasChars a => a -> Int
#

Get the real length of a string, taking into account combining and double-wide characters. Ambiguous characters are treated as width 2.

Char properties

3 declarations
valueisZWJ :: Char -> Bool
#

Checks whether a character is a zero-width joiner.

Types

3 declarations
datadata Doc a
#

Document, including structure relevant for layout.

Constructors

Instances13Functor, Foldable, Traversable, Eq, Data, Ord, …
classclass (IsString a, Semigroup a, Monoid a, Show a) => HasChars a where
#

Class abstracting over various string types that can fold over characters. Minimal definition is foldrChar and foldlChar, but defining the other methods can give better performance.

Methods

Instances5HasChars
newtypenewtype Attributed a
#

A sequence of strings with font attributes.

Instances14Functor, Foldable, Traversable, Eq, Data, Ord, …