package pla

  1. Overview
  2. Docs
type buffer
type t

Main template type

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

Empty template

val newline : t

Template for a new line

val comma : t

Template for a comma ','

val commaspace : t

Template for a comma followed by a space ', '

val semi : t

Template for a semicolon ';'

val space : t

Template for a white space ' '

Templates of basic types
val string : string -> t

string str makes a template from a string str

val int : int -> t

int i makes a template from an integer value i

val float : float -> t

float f makes a template from a float value

val bool : bool -> t

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

val string_quoted : string -> t

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

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

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

val quote : t -> t

quote t makes a new template wrapped with double quotes

val parenthesize : t -> t

parenthesize t makes a new template wrapped by parenthesis

val indent : t -> t

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

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

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

val (++) : t -> t -> t

t1 ++ t2 equivalent to append t1 t2

val join : t list -> t

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

val join_sep : t -> t list -> t

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

val 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

val 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

val 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

val 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
val print : t -> string

print t returns the contents template t as a string

val write : string -> t -> unit

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

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