Module Parsexp__.Import
module Ppx_sexp_conv_lib : sig ... endinclude Sexplib0.Sexp_conv
type 'a sexp_option= 'a optiontype 'a sexp_list= 'a listtype 'a sexp_array= 'a arraytype 'a sexp_opaque= 'a
Conversion of OCaml-values to S-expressions
val default_string_of_float : (float -> string) Stdlib.refdefault_string_of_floatreference to the default function used to convert floats to strings.Initially set to
fun n -> sprintf "%.20G" n.
val write_old_option_format : bool Stdlib.refwrite_old_option_formatreference for the default option format used to write option values. If set totrue, the old-style option format will be used, the new-style one otherwise.Initially set to
true.
val read_old_option_format : bool Stdlib.refread_old_option_formatreference for the default option format used to read option values.Of_sexp_errorwill be raised with old-style option values if this reference is set tofalse. Reading new-style option values is always supported. Using a global reference instead of changing the converter calling conventions is the only way to avoid breaking old code with the standard macros.Initially set to
true.
val list_map : ('a -> 'b) -> 'a list -> 'b listWe re-export a tail recursive map function, because some modules override the standard library functions (e.g.
StdLabels) which wrecks havoc with the camlp4 extension.
val sexp_of_unit : unit -> Sexplib0.Sexp.tsexp_of_unit ()converts a value of typeunitto an S-expression.
val sexp_of_bool : bool -> Sexplib0.Sexp.tsexp_of_bool bconverts the valuexof typeboolto an S-expression.
val sexp_of_string : string -> Sexplib0.Sexp.tsexp_of_bool strconverts the valuestrof typestringto an S-expression.
val sexp_of_bytes : bytes -> Sexplib0.Sexp.tsexp_of_bool strconverts the valuestrof typebytesto an S-expression.
val sexp_of_char : char -> Sexplib0.Sexp.tsexp_of_char cconverts the valuecof typecharto an S-expression.
val sexp_of_int : int -> Sexplib0.Sexp.tsexp_of_int nconverts the valuenof typeintto an S-expression.
val sexp_of_float : float -> Sexplib0.Sexp.tsexp_of_float nconverts the valuenof typefloatto an S-expression.
val sexp_of_int32 : int32 -> Sexplib0.Sexp.tsexp_of_int32 nconverts the valuenof typeint32to an S-expression.
val sexp_of_int64 : int64 -> Sexplib0.Sexp.tsexp_of_int64 nconverts the valuenof typeint64to an S-expression.
val sexp_of_nativeint : nativeint -> Sexplib0.Sexp.tsexp_of_nativeint nconverts the valuenof typenativeintto an S-expression.
val sexp_of_ref : ('a -> Sexplib0.Sexp.t) -> 'a Stdlib.ref -> Sexplib0.Sexp.tsexp_of_ref conv rconverts the valuerof type'a refto an S-expression. Usesconvto convert values of type'ato an S-expression.
val sexp_of_lazy_t : ('a -> Sexplib0.Sexp.t) -> 'a lazy_t -> Sexplib0.Sexp.tsexp_of_lazy_t conv lconverts the valuelof type'a lazy_tto an S-expression. Usesconvto convert values of type'ato an S-expression.
val sexp_of_option : ('a -> Sexplib0.Sexp.t) -> 'a option -> Sexplib0.Sexp.tsexp_of_option conv optconverts the valueoptof type'a optionto an S-expression. Usesconvto convert values of type'ato an S-expression.
val sexp_of_pair : ('a -> Sexplib0.Sexp.t) -> ('b -> Sexplib0.Sexp.t) -> ('a * 'b) -> Sexplib0.Sexp.tsexp_of_pair conv1 conv2 pairconverts a pair to an S-expression. It uses its first argument to convert the first element of the pair, and its second argument to convert the second element of the pair.
val sexp_of_triple : ('a -> Sexplib0.Sexp.t) -> ('b -> Sexplib0.Sexp.t) -> ('c -> Sexplib0.Sexp.t) -> ('a * 'b * 'c) -> Sexplib0.Sexp.tsexp_of_triple conv1 conv2 conv3 tripleconverts a triple to an S-expression usingconv1,conv2, andconv3to convert its elements.
val sexp_of_list : ('a -> Sexplib0.Sexp.t) -> 'a list -> Sexplib0.Sexp.tsexp_of_list conv lstconverts the valuelstof type'a listto an S-expression. Usesconvto convert values of type'ato an S-expression.
val sexp_of_array : ('a -> Sexplib0.Sexp.t) -> 'a array -> Sexplib0.Sexp.tsexp_of_array conv arconverts the valuearof type'a arrayto an S-expression. Usesconvto convert values of type'ato an S-expression.
val sexp_of_hashtbl : ('a -> Sexplib0.Sexp.t) -> ('b -> Sexplib0.Sexp.t) -> ('a, 'b) Stdlib.Hashtbl.t -> Sexplib0.Sexp.tsexp_of_hashtbl conv_key conv_value htblconverts the valuehtblof type('a, 'b) Hashtbl.tto an S-expression. Usesconv_keyto convert the hashtable keys of type'a, andconv_valueto convert hashtable values of type'bto S-expressions.
val sexp_of_opaque : 'a -> Sexplib0.Sexp.tsexp_of_opaque xconverts the valuexof opaque type to an S-expression. This means the user need not provide converters, but the result cannot be interpreted.
val sexp_of_fun : ('a -> 'b) -> Sexplib0.Sexp.tsexp_of_fun fconverts the valuefof function type to a dummy S-expression. Functions cannot be serialized as S-expressions, but at least a placeholder can be generated for pretty-printing.
Conversion of S-expressions to OCaml-values
exceptionOf_sexp_error of exn * Sexplib0.Sexp.tOf_sexp_error (exn, sexp)the exception raised when an S-expression could not be successfully converted to an OCaml-value.
val record_check_extra_fields : bool Stdlib.refrecord_check_extra_fieldschecks for extra (= unknown) fields in record S-expressions.
val of_sexp_error : string -> Sexplib0.Sexp.t -> 'aof_sexp_error reason sexp- raises Of_sexp_error
(Failure reason, sexp).
val of_sexp_error_exn : exn -> Sexplib0.Sexp.t -> 'aof_sexp_error exc sexp- raises Of_sexp_error
(exc, sexp).
val unit_of_sexp : Sexplib0.Sexp.t -> unitunit_of_sexp sexpconverts S-expressionsexpto a value of typeunit.
val bool_of_sexp : Sexplib0.Sexp.t -> boolbool_of_sexp sexpconverts S-expressionsexpto a value of typebool.
val string_of_sexp : Sexplib0.Sexp.t -> stringstring_of_sexp sexpconverts S-expressionsexpto a value of typestring.
val bytes_of_sexp : Sexplib0.Sexp.t -> bytesbytes_of_sexp sexpconverts S-expressionsexpto a value of typebytes.
val char_of_sexp : Sexplib0.Sexp.t -> charchar_of_sexp sexpconverts S-expressionsexpto a value of typechar.
val int_of_sexp : Sexplib0.Sexp.t -> intint_of_sexp sexpconverts S-expressionsexpto a value of typeint.
val float_of_sexp : Sexplib0.Sexp.t -> floatfloat_of_sexp sexpconverts S-expressionsexpto a value of typefloat.
val int32_of_sexp : Sexplib0.Sexp.t -> int32int32_of_sexp sexpconverts S-expressionsexpto a value of typeint32.
val int64_of_sexp : Sexplib0.Sexp.t -> int64int64_of_sexp sexpconverts S-expressionsexpto a value of typeint64.
val nativeint_of_sexp : Sexplib0.Sexp.t -> nativeintnativeint_of_sexp sexpconverts S-expressionsexpto a value of typenativeint.
val ref_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a Stdlib.refref_of_sexp conv sexpconverts S-expressionsexpto a value of type'a refusing conversion functionconv, which converts an S-expression to a value of type'a.
val lazy_t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a lazy_tlazy_t_of_sexp conv sexpconverts S-expressionsexpto a value of type'a lazy_tusing conversion functionconv, which converts an S-expression to a value of type'a.
val option_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a optionoption_of_sexp conv sexpconverts S-expressionsexpto a value of type'a optionusing conversion functionconv, which converts an S-expression to a value of type'a.
val pair_of_sexp : (Sexplib0.Sexp.t -> 'a) -> (Sexplib0.Sexp.t -> 'b) -> Sexplib0.Sexp.t -> 'a * 'bpair_of_sexp conv1 conv2 sexpconverts S-expressionsexpto a pair of type'a * 'busing conversion functionsconv1andconv2, which convert S-expressions to values of type'aand'brespectively.
val triple_of_sexp : (Sexplib0.Sexp.t -> 'a) -> (Sexplib0.Sexp.t -> 'b) -> (Sexplib0.Sexp.t -> 'c) -> Sexplib0.Sexp.t -> 'a * 'b * 'ctriple_of_sexp conv1 conv2 conv3 sexpconverts S-expressionsexpto a triple of type'a * 'b * 'cusing conversion functionsconv1,conv2, andconv3, which convert S-expressions to values of type'a,'b, and'crespectively.
val list_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a listlist_of_sexp conv sexpconverts S-expressionsexpto a value of type'a listusing conversion functionconv, which converts an S-expression to a value of type'a.
val array_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a arrayarray_of_sexp conv sexpconverts S-expressionsexpto a value of type'a arrayusing conversion functionconv, which converts an S-expression to a value of type'a.
val hashtbl_of_sexp : (Sexplib0.Sexp.t -> 'a) -> (Sexplib0.Sexp.t -> 'b) -> Sexplib0.Sexp.t -> ('a, 'b) Stdlib.Hashtbl.thashtbl_of_sexp conv_key conv_value sexpconverts S-expressionsexpto a value of type('a, 'b) Hashtbl.tusing conversion functionconv_key, which converts an S-expression to hashtable key of type'a, and functionconv_value, which converts an S-expression to hashtable value of type'b.
val opaque_of_sexp : Sexplib0.Sexp.t -> 'aopaque_of_sexp sexp- raises Of_sexp_error
when attempting to convert an S-expression to an opaque value.
val fun_of_sexp : Sexplib0.Sexp.t -> 'afun_of_sexp sexp- raises Of_sexp_error
when attempting to convert an S-expression to a function.
val sexp_of_exn : exn -> Sexplib0.Sexp.tsexp_of_exn excconverts exceptionexcto an S-expression. If no suitable converter is found, the standard converter inPrintexcwill be used to generate an atomic S-expression.
val sexp_of_exn_opt : exn -> Sexplib0.Sexp.t optionsexp_of_exn_opt excconverts exceptionexctoSome sexp. If no suitable converter is found,Noneis returned instead.
module Exn_converter = Sexplib0.Sexp_conv.Exn_converter