Common combinators.
The document (x |/| y)
concatenates document x
and y
with a
'softline' in between. This effectively puts x
and y
either
next to each other (with a space
in between) or underneath each
other.
The document (x |//| y)
concatenates document x
and y
with
a 'softbreak' in between. This effectively puts x
and y
either
right next to each other or underneath each other.
The document (x |+| y)
concatenates document x
and document
y
. It is an associative operation having 'empty' as a left and
right unit.
The document (x |++| y)
concatenates document x
and y
with a
space
in between.
The document (x |$| y)
concatenates document x
and y
with a
line
in between.
The document (x |$$| y)
concatenates document x
and y
with
a linebreak
in between.
The document (vsep xs)
concatenates all documents xs
vertically with (|$|)
. If a 'group' undoes the line breaks
inserted by vsep
, all documents are separated with a space.
The document (vcat xs)
concatenates all documents xs
vertically with (|$$|)
. If a group
undoes the line breaks
inserted by vcat
, all documents are directly concatenated.
The document (tupled xs)
comma separates the documents xs
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.
The document softLine
behaves like space
if the resulting
output fits the page, otherwise it behaves like line
.
The document softbreak
behaves like empty
if the resulting
output fits the page, otherwise it behaves like 'line'.
The document (set xs)
separates the documents xs
with
commas and encloses them in braces. The documents are
rendered horizontally if that fits the page. Otherwise they are
aligned vertically. All comma's are put in front of the
elements.
The document (sep xs)
concatenates all documents xs
either
horizontally with (|++|)
, if it fits the page, or vertically with
(|$|)
.
The document (semiBraces xs)
separates the documents xs
with
semi-colon and encloses them in braces. The documents are
rendered horizontally if that fits the page. Otherwise they are
aligned vertically. All semi-colons's are put in front of the
elements.
(punctuate p xs)
concatenates all documents in xs
with
document p
except for the last document.
The document (literal s)
concatenates all characters in s
using line
for newline characters and char
for all other
characters. It is used instead of 'text' whenever the text contains
newline characters.
The document (list xs)
comma separates the documents xs
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.
The document (indent i x)
indents document x
with i
spaces.
The document (hsep xs)
concatenates all documents xs
horizontally with (|++|)
.
The document (hcat xs)
concatenates all documents xs
horizontally with (|+|)
.
The hang combinator implements hanging indentation. The document
(hang i x)
renders document x
with a nesting level set to the
current column plus i
.
The document (fillSep xs)
concatenates documents xs
horizontally with (|++|)
as long as its fits the page, than
inserts a line
and continues doing that for all documents in
xs
.
The document (fillCat xs)
concatenates documents xs
horizontally with (|+|)
as long as its fits the page, than inserts
a linebreak
and continues doing that for all documents in xs
.
The document (fillBreak i x)
first renders document x
. It
than appends space
s until the width is equal to i
. If the
width of x
is already larger than i
, the nesting level is
increased by i
and a line
is appended.
The document (fill i x)
renders document x
. It than appends
space
s until the width is equal to i
. If the width of x
is
already larger, nothing is appended. This combinator is quite
useful in practice to output a list of bindings.
The document (encloseSep l r sep xs)
concatenates the documents
xs
separated by sep
and encloses the resulting document by l
and r
. The documents are rendered horizontally if that fits the
page. Otherwise they are aligned vertically. All separators are put
in front of the elements.
The document (enclose l r x)
encloses document x
between
documents l
and r
using (|+|)
.
The document (cat xs)
concatenates all documents xs
either
horizontally with (|+|)
, if it fits the page, or vertically with
(|$$|)
.
The document (align x)
renders document x
with the nesting
level set to the current column. It is used for example to
implement 'hang'.