Averest


Printer Module

This module implements functions for structured pretty printing. In general, the functions obtain a value to be printed, and a printer driver and will then generates a printer. A printer driver is thereby a function of type PrnDrv : (string -> unit) that will later on consume a string to print it. Such a printer driver is given to a printer which has consequently type PrnDrv -> unit to finally print the value. Hence, given a printer driver p:PrnDrv, and a printer P:Printer, the function application (P p) finally prints the value that was used to generate the printer P. A pretty printer is function that maps a given precedence to a Printer. This concept allows one to easily print all kinds of values into files, strings, and output streams.

Types

Type Description

PPrinter

a pretty printer requires in addition a precedence

Printer

a printer receives a printer driver generated from an object to print it

PrnDrv

printer driver consume a string for printing it

Functions and values

Function or value Description

DecIndent strFn

Full Usage: DecIndent strFn

Parameters:

decrease global identation

strFn : PrnDrv

IncIndent strFn

Full Usage: IncIndent strFn

Parameters:

increase global identation

strFn : PrnDrv

Prn2File filename prnFn

Full Usage: Prn2File filename prnFn

Parameters:
    filename : string
    prnFn : (string -> unit) -> unit

prints print function to file

filename : string
prnFn : (string -> unit) -> unit

Prn2Print prnFn

Full Usage: Prn2Print prnFn

Parameters:

prints given print function to stdout

prnFn : Printer

Prn2Str prnFn

Full Usage: Prn2Str prnFn

Parameters:
Returns: string

converts print function to string

prnFn : Printer
Returns: string

Prn2Stream stream prnFn

Full Usage: Prn2Stream stream prnFn

Parameters:
Returns: 'a

prints print function to an outstream

stream : StreamWriter
prnFn : (string -> unit) -> 'a
Returns: 'a

PrnApp prnFn seqL strFn

Full Usage: PrnApp prnFn seqL strFn

Parameters:
    prnFn : 'a -> PrnDrv -> unit
    seqL : 'a list
    strFn : PrnDrv

apply a printing function to a list of printing functions

prnFn : 'a -> PrnDrv -> unit
seqL : 'a list
strFn : PrnDrv

PrnBL bl

Full Usage: PrnBL bl

Parameters:
    bl : bool list

Returns: PrnDrv -> unit

bl : bool list
Returns: PrnDrv -> unit

PrnBlock seqL strFn

Full Usage: PrnBlock seqL strFn

Parameters:

print an indented block

seqL : (PrnDrv -> unit) list
strFn : PrnDrv

PrnBool b

Full Usage: PrnBool b

Parameters:
    b : bool

Returns: PrnDrv -> unit

b : bool
Returns: PrnDrv -> unit

PrnCR strFn

Full Usage: PrnCR strFn

Parameters:

print end of line

strFn : PrnDrv

PrnCRn n

Full Usage: PrnCRn n

Parameters:
    n : int

Returns: PrnDrv -> unit

print n linebreaks

n : int
Returns: PrnDrv -> unit

PrnDup copies prnFn strFn

Full Usage: PrnDup copies prnFn strFn

Parameters:

duplicate the given printing function n times

copies : int
prnFn : Printer
strFn : PrnDrv

PrnFlushLeft prnFn strFn

Full Usage: PrnFlushLeft prnFn strFn

Parameters:

prints a line and ignores indentation

prnFn : PrnDrv -> unit
strFn : PrnDrv

PrnIndent strFn

Full Usage: PrnIndent strFn

Parameters:

print identation

strFn : PrnDrv

PrnInt n

Full Usage: PrnInt n

Parameters:
    n : 'a

Returns: PrnDrv -> unit

n : 'a
Returns: PrnDrv -> unit

PrnJoin prnFnb prnFnList strFn

Full Usage: PrnJoin prnFnb prnFnList strFn

Parameters:

takes a list of printing function and another printing function, which is printed between each element of the list

prnFnb : PrnDrv -> unit
prnFnList : (PrnDrv -> unit) list
strFn : PrnDrv

PrnLabelledBlock label ch strFn

Full Usage: PrnLabelledBlock label ch strFn

Parameters:

print all elements of the list in an indented block that is labelled by "label"

label : string
ch : (PrnDrv -> unit) list
strFn : PrnDrv

PrnLabelledLine label ch strFn

Full Usage: PrnLabelledLine label ch strFn

Parameters:

print labelled line

label : string
ch : (PrnDrv -> unit) list
strFn : PrnDrv

PrnLine seqL strFn

Full Usage: PrnLine seqL strFn

Parameters:

print a sequence in an indented line

seqL : (PrnDrv -> unit) list
strFn : PrnDrv

PrnList seqL strFn

Full Usage: PrnList seqL strFn

Parameters:

call a list of print functions

seqL : (PrnDrv -> unit) list
strFn : PrnDrv

PrnMap prnFn seqL

Full Usage: PrnMap prnFn seqL

Parameters:
    prnFn : 'a -> 'b
    seqL : 'a list

Returns: 'b list

map sequence of elements

prnFn : 'a -> 'b
seqL : 'a list
Returns: 'b list

PrnNat n

Full Usage: PrnNat n

Parameters:
    n : 'a

Returns: PrnDrv -> unit

n : 'a
Returns: PrnDrv -> unit

PrnNo strFn

Full Usage: PrnNo strFn

Parameters:

print nothing

strFn : PrnDrv

PrnParamBlock param ch strFn

Full Usage: PrnParamBlock param ch strFn

Parameters:

print all elements of the list in an indented block that is labelled by the printing function param

param : PrnDrv -> unit
ch : (PrnDrv -> unit) list
strFn : PrnDrv

PrnParamLine param ch strFn

Full Usage: PrnParamLine param ch strFn

Parameters:

print labelled line

param : PrnDrv -> unit
ch : (PrnDrv -> unit) list
strFn : PrnDrv

PrnReal n

Full Usage: PrnReal n

Parameters:
    n : 'a

Returns: PrnDrv -> unit

n : 'a
Returns: PrnDrv -> unit

PrnSP strFn

Full Usage: PrnSP strFn

Parameters:

print space

strFn : PrnDrv

PrnSPn n

Full Usage: PrnSPn n

Parameters:
    n : int

Returns: PrnDrv -> unit

print n spaces

n : int
Returns: PrnDrv -> unit

PrnString s strFn

Full Usage: PrnString s strFn

Parameters:

s : string
strFn : PrnDrv

PrnStringLine str strFn

Full Usage: PrnStringLine str strFn

Parameters:

print a string in a indented line

str : string
strFn : PrnDrv

PrnXMLAttributes attrList

Full Usage: PrnXMLAttributes attrList

Parameters:
    attrList : (string * string) list

Returns: string

write XML attributes

attrList : (string * string) list
Returns: string

PrnXMLElem tag attributes childs strFn

Full Usage: PrnXMLElem tag attributes childs strFn

Parameters:
    tag : string
    attributes : (string * string) list
    childs : (PrnDrv -> unit) list
    strFn : PrnDrv

write an XML element to output stream os

tag : string
attributes : (string * string) list
childs : (PrnDrv -> unit) list
strFn : PrnDrv

PrnXMLElemBlock tag attributes childs

Full Usage: PrnXMLElemBlock tag attributes childs

Parameters:
    tag : string
    attributes : (string * string) list
    childs : (PrnDrv -> unit) list

Returns: PrnDrv -> unit

write an XML element to output stream os

tag : string
attributes : (string * string) list
childs : (PrnDrv -> unit) list
Returns: PrnDrv -> unit

PrnXMLElemLine tag attributes childs

Full Usage: PrnXMLElemLine tag attributes childs

Parameters:
    tag : string
    attributes : (string * string) list
    childs : (PrnDrv -> unit) list

Returns: PrnDrv -> unit

write an XML element to output stream os

tag : string
attributes : (string * string) list
childs : (PrnDrv -> unit) list
Returns: PrnDrv -> unit

PrnXMLPrologue strFn

Full Usage: PrnXMLPrologue strFn

Parameters:

write an XML declaration to output stream os

strFn : PrnDrv

indentDepth

Full Usage: indentDepth

Returns: int ref

Returns: int ref

indentString

Full Usage: indentString

Returns: string

Returns: string

leftDelim

Full Usage: leftDelim

Returns: string

left and right delimiters for grouping

Returns: string

maxPrec

Full Usage: maxPrec

Returns: int

maximal precedence value for operators

Returns: int

prnArr eL precOut strFn

Full Usage: prnArr eL precOut strFn

Parameters:
    eL : (int -> PrnDrv -> unit) list
    precOut : int
    strFn : PrnDrv

print array constant, [e1, ..., en]

eL : (int -> PrnDrv -> unit) list
precOut : int
strFn : PrnDrv

prnBlock ch precOut strFn

Full Usage: prnBlock ch precOut strFn

Parameters:
    ch : seq<(int -> PrnDrv -> unit)>
    precOut : int
    strFn : PrnDrv

print all elements of the list in an indented block

ch : seq<(int -> PrnDrv -> unit)>
precOut : int
strFn : PrnDrv

prnBool b

Full Usage: prnBool b

Parameters:
    b : bool

Returns: int -> Printer

b : bool
Returns: int -> Printer

prnFun fsym eL precOut strFn

Full Usage: prnFun fsym eL precOut strFn

Parameters:
    fsym : string
    eL : (int -> PrnDrv -> unit) list
    precOut : int
    strFn : PrnDrv

print function, e.g.: fsym(e1, ..., en)

fsym : string
eL : (int -> PrnDrv -> unit) list
precOut : int
strFn : PrnDrv

prnInfix precIn rator (arg1, arg2) precOut strFn

Full Usage: prnInfix precIn rator (arg1, arg2) precOut strFn

Parameters:
    precIn : int
    rator : string
    arg1 : PPrinter
    arg2 : int -> PrnDrv -> unit
    precOut : int
    strFn : PrnDrv

print infix operator, e.g.: arg1+arg2

precIn : int
rator : string
arg1 : PPrinter
arg2 : int -> PrnDrv -> unit
precOut : int
strFn : PrnDrv

prnInt n

Full Usage: prnInt n

Parameters:
    n : 'a

Returns: int -> Printer

n : 'a
Returns: int -> Printer

prnLine ch precOut strFn

Full Usage: prnLine ch precOut strFn

Parameters:
    ch : seq<(int -> PrnDrv -> unit)>
    precOut : int
    strFn : PrnDrv

print line

ch : seq<(int -> PrnDrv -> unit)>
precOut : int
strFn : PrnDrv

prnList eFn eL precOut strFn

Full Usage: prnList eFn eL precOut strFn

Parameters:
    eFn : 'a -> int -> PrnDrv -> unit
    eL : 'a list
    precOut : int
    strFn : PrnDrv

print sequence of elements by using printing function eFn

eFn : 'a -> int -> PrnDrv -> unit
eL : 'a list
precOut : int
strFn : PrnDrv

prnMap eFn eL

Full Usage: prnMap eFn eL

Parameters:
    eFn : 'a -> 'b
    eL : 'a list

Returns: 'b list

map sequence of elements

eFn : 'a -> 'b
eL : 'a list
Returns: 'b list

prnNat n

Full Usage: prnNat n

Parameters:
    n : 'a

Returns: int -> Printer

n : 'a
Returns: int -> Printer

prnPostfix precIn rator arg precOut strFn

Full Usage: prnPostfix precIn rator arg precOut strFn

Parameters:
    precIn : int
    rator : string
    arg : PPrinter
    precOut : int
    strFn : PrnDrv

print postfix operator, e.g.: arg+

precIn : int
rator : string
arg : PPrinter
precOut : int
strFn : PrnDrv

prnPrefix precIn rator arg precOut strFn

Full Usage: prnPrefix precIn rator arg precOut strFn

Parameters:
    precIn : int
    rator : string
    arg : PPrinter
    precOut : int
    strFn : PrnDrv

print prefix operator, e.g.: +arg

precIn : int
rator : string
arg : PPrinter
precOut : int
strFn : PrnDrv

prnQuant precIn quant (arg1, arg2, arg3) precOut strFn

Full Usage: prnQuant precIn quant (arg1, arg2, arg3) precOut strFn

Parameters:
    precIn : int
    quant : string
    arg1 : PPrinter
    arg2 : int -> PrnDrv -> unit
    arg3 : int -> PrnDrv -> unit
    precOut : int
    strFn : PrnDrv

print quantifier, e.g.: !arg1:arg2. arg3

precIn : int
quant : string
arg1 : PPrinter
arg2 : int -> PrnDrv -> unit
arg3 : int -> PrnDrv -> unit
precOut : int
strFn : PrnDrv

prnRoundfix rator1 rator2 arg precOut strFn

Full Usage: prnRoundfix rator1 rator2 arg precOut strFn

Parameters:
    rator1 : string
    rator2 : string
    arg : PPrinter
    precOut : int
    strFn : PrnDrv

print roundfix operator, e.g.:

rator1 : string
rator2 : string
arg : PPrinter
precOut : int
strFn : PrnDrv

prnSeq eL precOut strFn

Full Usage: prnSeq eL precOut strFn

Parameters:
    eL : seq<(int -> PrnDrv -> unit)>
    precOut : int
    strFn : PrnDrv

print sequence of elements

eL : seq<(int -> PrnDrv -> unit)>
precOut : int
strFn : PrnDrv

prnString str

Full Usage: prnString str

Parameters:
    str : string

Returns: int -> Printer

str : string
Returns: int -> Printer

prnTernary precIn rator1 rator2 (arg1, arg2, arg3) precOut strFn

Full Usage: prnTernary precIn rator1 rator2 (arg1, arg2, arg3) precOut strFn

Parameters:
    precIn : int
    rator1 : string
    rator2 : string
    arg1 : PPrinter
    arg2 : int -> PrnDrv -> unit
    arg3 : int -> PrnDrv -> unit
    precOut : int
    strFn : PrnDrv

print ternary infix operator, e.g.: arg1 => arg2 | arg3

precIn : int
rator1 : string
rator2 : string
arg1 : PPrinter
arg2 : int -> PrnDrv -> unit
arg3 : int -> PrnDrv -> unit
precOut : int
strFn : PrnDrv

prnTop prnFn precOut

Full Usage: prnTop prnFn precOut

Parameters:
Returns: Printer

converter to normal printing functions

prnFn : Printer
precOut : int
Returns: Printer

rightDelim

Full Usage: rightDelim

Returns: string

Returns: string