package prettym

  1. Overview
  2. Docs

Module PrettymSource

Sourcetype ppf

Abstract data corresponding to the encoder state and all its machinery.

Sourcetype 'a t = ppf -> 'a -> ppf

The type for formatters of values of type 'a.

Sourcetype ('ty, 'v) order
Sourceval keval_order : (ppf -> 'v) -> ppf -> ('ty, 'v) order -> 'ty
Sourceval break : indent:int -> len:int -> ('v, 'v) order

break ~indent ~len tries to add len spaces into the current line. If it fails - if we overflow the current line - we insert a new_line and fill the beginning of the new line with indent space characters.

Sourceval fws : ('v, 'v) order

fws is a specialization of break with indent = 1 and spaces = 1. This is the most used token to express an opportunity to break the line and be conform to RFC 822 and the folding-whitespace token.

Sourceval spaces : int -> ('v, 'v) order

spaces n is a specialization of break with spaces = n.

Sourceval cut : ('v, 'v) order

cut gives an opportunity to add a break line without indentation and spaces.

Sourceval const : 'a t -> 'a -> ('v, 'v) order

const pp v serialize v with pp.

Sourceval atom : 'a t -> ('a -> 'v, 'v) order

atom pp expects a value 'a and serialize it with pp.

Sourceval a : ('a t -> 'a -> 'v, 'v) order

a expects a serializer pp and a value to serialize it then.

Sourceval (!!) : 'a t -> ('a -> 'v, 'v) order

Alias of atom.

Sourceval ($) : 'a t -> 'a -> ('v, 'v) order

Alias of const.

Sourceval new_line : ('v, 'v) order

new_line inserts a new line regardless how many bytes the current line has.

Sourceval tbox : int -> ('v, 'v) order

tbox indent creates a new box to indent any contents inside with indent spaces.

Sourceval bbox : ('v, 'v) order

bbox creates a new box to indent any contents at the current position of the serializer.

Sourceval box : ('v, 'v) order
Sourceval close : ('v, 'v) order

close closes any boxes.

Sourceval using : ('b -> 'a) -> 'a t -> 'b t

using f pp apply f on the value and use pp then to serialize the result.

Sourceval string : string t

string permits to serialize a string.

Sourceval bytes : Bytes.t t

bytes permits to serialize a bytes.

Sourceval bigstring : Bigstringaf.t t

bigstring permits to serialize a bigstring.

Sourceval breakable : string t

breakable permits to serialize a breakable string. If the given string is larger than the margin, the serializer is able to break the string to fit under the margin instead of to wait an opportunity (such as cut or fws) to break the line.

Sourceval char : char t

char permits to serialize a char.

Sourceval list : sep:('x t * 'x) -> 'v t -> 'v list t

list ~sep pp permits to serialize a list of values which can be serialized with pp. Between each values, we apply sep.

Sourceval option : 'a t -> 'a option t
Sourcetype ('ty, 'v) fmt =
  1. | [] : ('v, 'v) fmt
  2. | :: : ('x, 'v) order * ('v, 'r) fmt -> ('x, 'r) fmt
Sourceval concat : ('a, 'b) fmt -> ('b, 'c) fmt -> ('a, 'c) fmt
Sourceval keval : (ppf -> 'v) -> ppf -> ('ty, 'v) fmt -> 'ty
Sourceval eval : ppf -> ('ty, ppf) fmt -> 'ty
Sourcemodule Buffer : sig ... end
Sourcemodule IOVec : sig ... end
Sourceval io_buffer_size : int
Sourceval create : ?margin:int -> ?new_line:string -> emitter:(IOVec.t list -> int) -> int -> ppf

create ?margin ?new_line ~emitter weight creates a serializer bounded to weight elements. The serializer is limiter to emit margin bytes per lines and break the line with new_line (default to "\r\n").

emitter is called when the serializer is full. It gives to user what it needs to transmit to the output and it asks how many bytes the user was able to transmit.

Sourceval is_empty : ppf -> bool

is_empty ppf returns true if the serializer is empty. Otherwise, it returns false.

Sourceval flush : ppf -> ppf

flush ppf enforces the serializer to call the internal emitter to transmit out what is serialized - even if ppf is not full.

Sourceval kflush : (ppf -> 'v) -> ppf -> 'v

kflush is flush with a kontinuation.

Sourceval to_string : ?margin:int -> ?new_line:string -> 'a t -> 'a -> string

to_string ?margin ?new_line pp v serializes a value v with the serializer pp into a string.

Sourceval to_stream : ?margin:int -> ?new_line:string -> 'a t -> 'a -> unit -> string option

to_stream ?margin ?new_line pp v serializes a value v with the serializer pp and it returns a function unit -> string option to transmit out the result chunk by chunk of the serialization.

OCaml

Innovation. Community. Security.