Module Serialkit_sexp.Sexpg

S-expression generation.

Generation

type t

The type for generated s-expressions.

val atom : string -> t

atom s is s as an atom.

type lyst

The type for generated s-expression lists.

val ls : lyst

ls starts a list.

val le : lyst -> t

le l ends lists l.

val el : t -> lyst -> lyst

el e l is list l with e added at the end.

val el_if : bool -> (unit -> t) -> lyst -> lyst

el cond v l is el (v ()) l if cond is true and l otherwise.

Derived generators

val atomf : ('a, Stdlib.Format.formatter, unit, t) Stdlib.format4 -> 'a

atomf fmt ... is an atom formatted according to fmt.

val bool : bool -> t

bool b is atomf "%b" b.

val int : int -> t

int i is atomf "%d" i.

val float : float -> t

float f is atomf "%g" f.

val float_hex : float -> t

float_hex f is atomf "%h" f.

val string : string -> t

string s is atom.

val option : ('a -> t) -> 'a option -> t

option some o is o as the none atom if o is none and a list starting with some atom followed by some v if o is Some v.

val list : ('a -> t) -> 'a list -> t

list el l is l as a list whose elements are generated using el.

val sexp : Sexp.t -> t

sexp s is the s-expression s as a generated value.

Output

val buffer_add : Stdlib.Buffer.t -> t -> unit

buffer_add b g adds the generated s-expression value g to b.

val to_string : t -> string

to_string g is the generated s-expression value g as a string.