package pla

  1. Overview
  2. Docs

Module PlaSource

Sourcetype options = {
  1. indent_size : int;
}
Sourcetype buffer
Sourcetype t

Main template type

Sourceval make : (buffer -> unit) -> t
Builtin templates
Sourceval unit : t

Empty template

Sourceval newline : t

Template for a new line

Sourceval comma : t

Template for a comma ','

Sourceval commaspace : t

Template for a comma followed by a space ', '

Sourceval semi : t

Template for a semicolon ';'

Sourceval space : t

Template for a white space ' '

Templates of basic types
Sourceval string : string -> t

string str makes a template from a string str

Sourceval int : int -> t

int i makes a template from an integer value i

Sourceval float : float -> t

float f makes a template from a float value

Sourceval bool : bool -> t

bool b makes a template from a bool value that produces 'true' or 'false'

Sourceval string_quoted : string -> t

string_quoted str makes a template from a string str but the contents are quoted

Functions to wrap templates
Sourceval wrap : t -> t -> t -> t

wrap left right t makes new template wrapped by the left and right templates

Sourceval quote : t -> t

quote t makes a new template wrapped with double quotes

Sourceval parenthesize : t -> t

parenthesize t makes a new template wrapped by parenthesis

Sourceval indent : t -> t

indent t makes an indented block with the contents of the template t

Functions to append templates
Sourceval append : t -> t -> t

append t1 t2 makes a new template with the contents of t1 followed by the contents of t2

Sourceval (++) : t -> t -> t

t1 ++ t2 equivalent to append t1 t2

Sourceval join : t list -> t

join elems makes a new template by appending the list elems of templates

Sourceval join_sep : t -> t list -> t

join sep elems makes a new template by appending the list elems of templates separated by sep

Sourceval join_sep_all : t -> t list -> t

join_sep_all sep elems similar to join_sep sep elems but also adds the separator after the last element

Sourceval map_join : ('a -> t) -> 'a list -> t

map_join f elems makes a new template by applying the function f to the list elems and appending them

Sourceval map_sep : t -> ('a -> t) -> 'a list -> t

map_sep sep f elems makes a new template by applying the function f to the list elems and appending them separated by the template sep

Sourceval map_sep_all : t -> ('a -> t) -> 'a list -> t

map_sep_all sep f elems similar to map_sep sep f elems but also adds the separator after the last element

Printing of templates
Sourceval print : ?options:options -> t -> string

print t returns the contents template t as a string

Sourceval write : ?options:options -> string -> t -> unit

write file t writes the contents of template t to file file

Sourceval buffer_newline : buffer -> unit
Sourceval buffer_indent : buffer -> unit
Sourceval buffer_outdent : buffer -> unit
Sourceval buffer_append : buffer -> string -> unit
Sourceval buffer_apply : t -> buffer -> unit
Sourcetype compiled
Sourceval create : string -> compiled
Sourceval set : string -> t -> compiled -> compiled
Sourceval seti : string -> int -> compiled -> compiled
Sourceval setf : string -> float -> compiled -> compiled
Sourceval sets : string -> string -> compiled -> compiled
Sourceval close : compiled -> t
OCaml

Innovation. Community. Security.