Page
Library
Module
Module type
Parameter
Class
Class type
Source
Treeprint.PrinterPretty printing combinator based on Format with automatic parenthese insertion
Type of the pretty printer combinator: under the given assoc position and precendence level, compute some 'a
Pretty printer combinator is a state monad
include Spotlib.Spot.Monad.T with type 'a t := 'a tinclude Spotlib.Monad_intf.EX1 with type 'a t := 'a tIteration with index starting from 0. Not tail recursive.
include Spotlib.Monad_intf.Infix1 with type 'a t := 'a tApplicative style binops
module S : Spotlib.Monad_intf.S1 with type 'a t := 'a tmodule EX : Spotlib.Monad_intf.EX1 with type 'a t := 'a tmodule Infix : Spotlib.Monad_intf.Infix1 with type 'a t := 'a t 1 Basic printer functions
val string : string -> pprstring s pretty-prints the string s
box n ppr creates a horizontal layout box. An internal call of space and cut may cause a line break if the entire contents do not fit with the current printable width. If a line break is required the following contents are printed with additional indentation of n.
vbox n ppr creates a vertical layout box. If the entire contents do not fit with the current printable width, all calls of space and cut cause line breaks. If a line break is required the following contents are printed with additional indentation of n.
val cut : pprA hint of a line break.
val space : pprA hint of a line break, preceded with a white space.
val flush : pprForce flushing. All the opened boxes are closed and a line break is inserted.
val nop : pprDo nothing
1 Level and environments
Compare the argument against the current level: `Same : the same as the current level `Stronger : the argument is stronger than the current `Weak : the argument is weaker than the current
Check the printer object of assoc and level requires parenthesis wrapping or not in the current environment
These implements common printing with auto parenthesis wrapping. Note: They may not suit with your own taste.
parenbox ?parens assoc level ppr pretty-prints ppr as an object of associativity assoc and precedence level. Parentheses '(' and ')' are automatically wrapped when required.
binop ?parens assoc level ~op left right pretty prints binary operation <left> <op> <right> where op has assoc and level. Parentheses '(' and ')' are automatically wrapped when required.
list ?parens lev sep pprs is to create a list without a box. lev is the level of the separator sep. Parentheses '(' and ')' are automatically wrapped when required.
prefix ?parens level ~op p pretty-prints an prefix operator application expression <op> <p> where op's level is level. Parentheses '(' and ')' are automatically wrapped when required.
postfix ?parens level ~op p pretty-prints an postfix operator application expression <p> <op> where op's level is level. Parentheses '(' and ')' are automatically wrapped when required.
parens left right ppr surrounds ppr with the left and right strings. The level used for pretty-printing the internal ppr is reset to -1.0 to prevent from having auto parens for it
Printing combinators which use the same operator assciativity and precedence as OCaml language.
module OCaml : sig ... endval format :
?assoc:assoc ->
?level:level ->
('a -> ppr) ->
Spotlib.Spot.Format.t ->
'a ->
unitformat ?assoc ?level conv ppf a pretty-prints a using the conversion function conv to the formatter ppf. The initial associativity and level are given by assoc and level.
buffer conv buf ?assoc ?level a pretty-prints a using the conversion function conv to the buffer buf. The initial associativity and level are given by assoc and level.
show conv ?assoc ?level a pretty-prints a using the conversion function conv then returns the result as a string. The initial associativity and level are given by assoc and level.
module MakeDrivers (M : sig ... end) : sig ... endFunctor version of drivers
module Test : sig ... end