IdrisDoc: Text.PrettyPrint.WL.Combinators

# Text.PrettyPrint.WL.Combinators

Common combinators.

(|/|) : Doc -> Doc -> Doc

  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.

  Fixity
    Left associative, precedence 5
(|//|) : Doc -> Doc -> Doc

  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.

  Fixity
    Left associative, precedence 5
(|+|) : Doc -> Doc -> Doc

  The document `(x |+| y)` concatenates document `x` and document
  `y`. It is an associative operation having 'empty' as a left and
  right unit.

  Fixity
    Left associative, precedence 6
(|++|) : Doc -> Doc -> Doc

  The document `(x |++| y)` concatenates document `x` and `y` with a
  `space` in between.

  Fixity
    Left associative, precedence 6
(|$|) : Doc -> Doc -> Doc

  The document `(x |$| y)` concatenates document `x` and `y` with a
  `line` in between.

  Fixity
    Left associative, precedence 5
(|$$|) : Doc -> Doc -> Doc

  The document `(x |$$| y)` concatenates document `x` and `y` with
  a `linebreak` in between.

  Fixity
    Left associative, precedence 5
width : Doc -> (Int -> Doc) -> Doc
vsep : List Doc -> Doc

  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.

vcat : List Doc -> Doc

  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.

tupled : List Doc -> Doc

  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.

squotes : Doc -> Doc
softLine : Doc

  The document `softLine` behaves like `space` if the resulting
  output fits the page, otherwise it behaves like `line`.

softBreak : Doc

  The document `softbreak` behaves like `empty` if the resulting
  output fits the page, otherwise it behaves like 'line'.

set : List Doc -> Doc

  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.

sep : List Doc -> Doc

  The document `(sep xs)` concatenates all documents `xs` either
  horizontally with `(|++|)`, if it fits the page, or vertically with
  `(|$|)`.

semiBrace : List Doc -> Doc

  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 : Doc -> List Doc -> List Doc

  `(punctuate p xs)` concatenates all documents in `xs` with
  document `p` except for the last document.

parens : Doc -> Doc
nat : Nat -> Doc
literal : (str : String) -> Doc

  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.

list : List Doc -> Doc

  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.

integer : Integer -> Doc
int : Int -> Doc
indent : Int -> Doc -> Doc

  The document `(indent i x)` indents document `x` with `i` spaces.

hsep : List Doc -> Doc

  The document `(hsep xs)` concatenates all documents `xs`
  horizontally with `(|++|)`.

hcat : List Doc -> Doc

  The document `(hcat xs)` concatenates all documents `xs`
  horizontally with `(|+|)`.

hang : Int -> Doc -> Doc

  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`.

fillSep : List Doc -> Doc

  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`.

fillCat : List Doc -> Doc

  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`.

fillBreak : (i : Int) -> (x : Doc) -> Doc

  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.

fill : (i : Int) -> (x : Doc) -> Doc

  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.

encloseSep : (l : Doc) -> (r : Doc) -> (sep : Doc) -> (xs : List Doc) -> Doc

  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.

enclose : Doc -> Doc -> Doc -> Doc

  The document `(enclose l r x)` encloses document `x` between
  documents `l` and `r` using `(|+|)`.

dquotes : Doc -> Doc
double : Double -> Doc
cat : List Doc -> Doc

  The document `(cat xs)` concatenates all documents `xs` either
  horizontally with `(|+|)`, if it fits the page, or vertically with
  `(|$$|)`.

brackets : Doc -> Doc
braces : Doc -> Doc
bool : Bool -> Doc
angles : Doc -> Doc
align : Doc -> Doc

  The document `(align x)` renders document `x` with the nesting
  level set to the current column. It is used for example to
  implement 'hang'.