FsPretty


PrettyPrint

Library of pretty printer primitives for constructing Doc document objects.

Nested types and modules

TypeDescription
Doc

A Doc represents a Document that has been constructed with the set of provided pretty printer combinators, and then rendered with one of the provided renderers.

Functions and values

Function or valueDescription
( <**> ) x y
Signature: x:Doc -> y:Doc -> Doc

Concatenate two Doc objects, separating them with a line break. This function was <$$> in Haskell.

( <*> ) x y
Signature: x:Doc -> y:Doc -> Doc

Concatenate two Doc objects, separating them with a line. This function was <$> in Haskell.

( <//> ) x y
Signature: x:Doc -> y:Doc -> Doc

Concatenate two documents with a softbreak in between them.

( </> ) x y
Signature: x:Doc -> y:Doc -> Doc

Concatenate two documents with a softline in between them.

( <+> ) x y
Signature: x:Doc -> y:Doc -> Doc

Concatenate two Doc objects, separated by a single space.

( <<>> ) x y
Signature: x:Doc -> y:Doc -> Doc

Infix notation for beside. In haskell this is <>, but this collides poorly with <> in F# so it was renamed.

align d
Signature: d:Doc -> Doc
angles
Signature: Doc -> Doc

Enclose a Doc in angle brackets.

backslash
Signature: Doc

'\' character.

beside x y
Signature: x:Doc -> y:Doc -> Doc

Place two documents side-by-side

braces
Signature: Doc -> Doc

Enclose a Doc in braces.

brackets
Signature: Doc -> Doc

Enclose a Doc in brackets.

cat
Signature: Doc list -> Doc

Concatenate all of the Documents horizontally if it fits a page or vertically if not.

colon
Signature: Doc

':' character.

column f
Signature: f:(int -> Doc) -> Doc
comma
Signature: Doc

',' character.

dot
Signature: Doc

'.' character.

dquote
Signature: Doc

'"' character.

dquotes
Signature: Doc -> Doc

Enclose a Doc in double quotes.

empty
Signature: Doc

The empty document.

enclose l r x
Signature: l:Doc -> r:Doc -> x:Doc -> Doc

Surround a Doc by a left and a right Doc.

encloseSep left right sep ds
Signature: left:Doc -> right:Doc -> sep:Doc -> ds:Doc list -> Doc

Enclose a list of Doc objects between a left and right Doc, and separate the list elements with the given separator Doc.

equals
Signature: Doc

'=' character.

fill f d
Signature: f:int -> d:Doc -> Doc

Render the given document and append spaces until the width is f. If the width is greather than f without added spaces then nothing is added.

fillBreak f x
Signature: f:int -> x:Doc -> Doc
fillCat
Signature: Doc list -> Doc

Concatenate all of the Docs horizontally as long as it fits the page and then insert a linebreak and continue doing so for the remaining Docs.

fillSep
Signature: Doc list -> Doc
flatten _arg1
Signature: _arg1:Doc -> Doc
fold f _arg1
Signature: f:(Doc -> Doc -> Doc) -> _arg1:Doc list -> Doc

Fold specialized to Doc types. Accepts only functions of type Doc -> Doc -> Doc, and returns the empty Doc when an empty list is provided.

group x
Signature: x:Doc -> Doc
hang i d
Signature: i:int -> d:Doc -> Doc
hcat
Signature: Doc list -> Doc

Horizontally concatenate a list of Doc objects.

hsep
Signature: Doc list -> Doc

Horizontally concatenate a list of Doc objects separated by spaces.

indent i d
Signature: i:int -> d:Doc -> Doc

Indent a Doc by the given number of spaces.

indentation
Signature: int -> string

Indentation is an alias for spaces.

langle
Signature: Doc

'<' character.

lbrace
Signature: Doc

'{' character.

lbracket
Signature: Doc

'[' character.

line
Signature: Doc
linebreak
Signature: Doc
lparen
Signature: Doc

'(' character.

mkbool _arg1
Signature: _arg1:bool -> Doc

Lift a bool into the Doc type.

mkchar c
Signature: c:char -> Doc

Lift a char into the Doc type.

mkdouble d
Signature: d:double -> Doc

Lift a double into the Doc type.

mkfloat f
Signature: f:float -> Doc

Lift a float into the Doc type.

mkint i
Signature: i:int -> Doc

Lift an integer into the Doc type.

mklist
Signature: Doc list -> Doc

Treat a list of Docs as a list [d1,d2,...,dN]

mkstring s
Signature: s:string -> Doc

Given a string with one or more lines of text separated by newline characters, create a sequence of Doc objects for each line and then fold the resulting Doc objects together with the <<>> operator with a line between each.

nest i x
Signature: i:int -> x:Doc -> Doc
nesting f
Signature: f:(int -> Doc) -> Doc
parens
Signature: Doc -> Doc

Enclose a Doc in parenthesis.

punctuate p _arg1
Signature: p:Doc -> _arg1:Doc list -> Doc list

Given a list of Doc objects and a punctuation Doc, return the list with each Doc except the last followed by the punctuation.

rangle
Signature: Doc

'>' character.

rbrace
Signature: Doc

'}' character.

rbracket
Signature: Doc

']' character.

rparen
Signature: Doc

')' character.

semi
Signature: Doc

';' character.

semiBraces
Signature: Doc list -> Doc

Treat a list of Docs as a semi-colon separated sequence between braces, such as {d1;d2;...;dN}

sep
Signature: Doc list -> Doc
softbreak
Signature: Doc

A softbreak behaves line empty if the output fits on one line, otherwise it behaves like a linebreak

softline
Signature: Doc

A softline behaves line empty if the output fits on one line, otherwise it behaves like a lineline

space
Signature: Doc

' ' character.

spaces _arg1
Signature: _arg1:int -> string

Produce a string with n spaces.

squote
Signature: Doc

''' character.

squotes
Signature: Doc -> Doc

Enclose a Doc in single quotes.

text s
Signature: s:string -> Doc

Lift a string into the Doc type.

tupled
Signature: Doc list -> Doc

Treat a list of Docs as a tuple (d1,d2,...,dN)

vcat
Signature: Doc list -> Doc

Vertical concatenation of a list of Docs.

vsep
Signature: Doc list -> Doc
width d f
Signature: d:Doc -> f:(int -> Doc) -> Doc
Fork me on GitHub