Ludwig.PrettyPrint

Module Members

bool

(Function)

Example:

bool(True) # => text"True"
bool(False) # => text"False"

Type Signature

 fun (Bool) -> Doc
Argument: x
Type: Bool
Returns:
Type: Doc

braces

(Function)

Like parens but with { and }

Type Signature

 fun (Doc) -> Doc
Argument: x
Type: Doc
Returns:
Type: Doc

brackets

(Function)

Like parens but with [ and ]

Type Signature

 fun (Doc) -> Doc
Argument: x
Type: Doc
Returns:
Type: Doc

concat

(Function)

x <> y concatenates documents x and y

Example:

text"abc" <> text"123" # => text"abc123"

Type Signature

 fun (Doc, Doc) -> Doc
Argument: x
Type: Doc
Argument: y
Type: Doc
Returns:
Type: Doc

concatLine

(Function)

x <$> y concatenates documents x and y with a line in between

Example:

concatLine(text"hello", text"world") # => text"hello\nworld"

Type Signature

 fun (Doc, Doc) -> Doc
Argument: x
Type: Doc
Argument: y
Type: Doc
Returns:
Type: Doc

concatLinebreak

(Function)

Concatenates documents x and y with a linebreak in between

Type Signature

 fun (Doc, Doc) -> Doc
Argument: x
Type: Doc
Argument: y
Type: Doc
Returns:
Type: Doc

concatSoftbreak

(Function)

Concatenates documents x and y with a softbreak in between

Type Signature

 fun (Doc, Doc) -> Doc
Argument: x
Type: Doc
Argument: y
Type: Doc
Returns:
Type: Doc

concatSoftline

(Function)

Concatenates documents x and y with a softline in between

Type Signature

 fun (Doc, Doc) -> Doc
Argument: x
Type: Doc
Argument: y
Type: Doc
Returns:
Type: Doc

concatSpace

(Function)

Concatenates documents x and y with a space in between

Example:

concatSpace(text"hello", text"world") # => text"hello world"

Type Signature

 fun (Doc, Doc) -> Doc
Argument: x
Type: Doc
Argument: y
Type: Doc
Returns:
Type: Doc

float

(Function)

Example:

float(123.0) # => text"123.0"

Type Signature

 fun (Float) -> Doc
Argument: x
Type: Float
Returns:
Type: Doc

group

(Function)

Used to specify alternative layouts. group(x) undoes all line breaks in document x. The resulting line is added to the current line if that fits the page. Otherwise, the document is rendered without any changes.

Type Signature

 fun (Doc) -> Doc
Argument: x
Type: Doc
Returns:
Type: Doc

indent

(Function)

indent n x indents x with n spaces

Example:

text"header" <> indent 4 <> text"* bullet point" # =>
text"header
    \    * bullet point"

Type Signature

 fun (Int, Doc) -> Doc
Argument: n
Type: Int
Argument: x
Type: Doc
Returns:
Type: Doc

int

(Function)

Example:

int(123) # => text"123"

Type Signature

 fun (Int) -> Doc
Argument: x
Type: Int
Returns:
Type: Doc

parens

(Function)

Encloses document x in parenthesis, ( and )

Example:

parens(float(3.0) <$$> text"*" <$$> float(1.0)) # => text"(3.0 * 1.0)"

Type Signature

 fun (Doc) -> Doc
Argument: x
Type: Doc
Returns:
Type: Doc

sep

(Function)

Concatenate all documents xs either horizontally with <+> as long as it fits the page or vertically with <$>

Type Signature

 fun (List<Doc>) -> Doc
Argument: xs
Type: List<Doc>
Returns:
Type: Doc

show

(Function)

Example:

show(text"hello") # => "hello"

Type Signature

 fun (Doc) -> String
Argument: x
Type: Doc
Returns:
Type: String

text

(Function)

Convert a Ludwig.String to Doc

Type Signature

 fun (String) -> Doc
Argument: x
Type: String
Returns:
Type: Doc

vsep

(Function)

Concatenate all documents xs vertically with <$>

Type Signature

 fun (List<Doc>) -> Doc
Argument: xs
Type: List<Doc>
Returns:
Type: Doc

<$$>

(Operator)

operator <$$> infixr 5:
  concatLinebreak

<$>

(Operator)

operator <$> infixr 5:
  concatLine

<+>

(Operator)

operator <+> infixr 6:
  concatSpace

<//>

(Operator)

operator <//> infixr 5:
  concatSoftbreak

</>

(Operator)

operator </> infixr 5:
  concatSoftline

<>

(Operator)

operator <> infixr 6:
  concat

Doc

(Type)

type opaque Doc

Type to represent pretty documents

line

(Value)

Doc line:
  __Ludwig_PrettyPrint_line

Advances to the next line

Example:

text"hello" <> line <> text"world" # => text"hello\nworld"

Type Signature

 Doc

linebreak

(Value)

Doc linebreak:
  __Ludwig_PrettyPrint_linebreak

Advances to the next line and indents to the current nesting level. Behaves like empty if the line break is undone by group

Type Signature

 Doc

softbreak

(Value)

Doc softbreak:
  __Ludwig_PrettyPrint_softbreak

Behaves like empty if the resulting output fits the page, otherwise it behaves like line

Type Signature

 Doc

softline

(Value)

Doc softline:
  __Ludwig_PrettyPrint_softline

Behaves like space if the resulting output fits the page, otherwise it behaves like line

Type Signature

 Doc

space

(Value)

Doc space:
  __Ludwig_PrettyPrint_space

Type Signature

 Doc