package ppx_meta_conv

  1. Overview
  2. Docs
PPX for converting between OCaml values and JSON, Sexp and camlon

Install

Dune Dependency

Authors

Maintainers

Sources

ppx_meta_conv-4.1.0.tar.gz
md5=aad544375f23a3979aafe9defdebf4bd
sha512=991ad7433c8f2f51b298d4c99b35b873aab66c5d1da1beaa18f8f58f8e708e5a4299f0bb657af9d12bfcd3d645f48b3efe21e13b8c62e303604bd374e88f7d3a

doc/ppx_meta_conv.runtime/Meta_conv/Coder/Make/Helper/index.html

Module Make.HelperSource

Useful tool functions for writing encoders+decoders of primitive types
Sourceval integer_of_float : float -> float -> (float -> 'int) -> float -> ('int, string) Result.t

float to integer conversion with error checks.

This is not target type dependent, but it is here for easier access.

Sourceval list_of : (target -> target list option) -> 'a decoder -> 'a list decoder

typical list_of_<targe_type>. It takes a function to get a list from a target value

Sourceval array_of : (target -> target list option) -> 'a decoder -> 'a array decoder

typical array_of_<targe_type>. It takes a function to get a list from a target value

Sourceval option_of : (target -> target option option) -> 'a decoder -> 'a option decoder

typical option_of_<targe_type>. It takes predicate to check the arg is a Some, None or something else.

Some (Some v) : Some for a target value v Some None : None None : : Error. Target value cannot have the option type

Sourceval ref_of : (target -> target option) -> 'a decoder -> 'a ref decoder

typical ref_of_<targe_type>. It takes predicate to check the arg is a reference or something else.

Some v : Found a record contents = <v> None : Error. Target value cannot have the option type

Sourceval lazy_t_of : (target Error.t -> 'a) -> 'a decoder -> 'a lazy_t decoder

typical lazy_t_of_<targe_type>. The decoding is done lazily. Error at the deferred decoding is handled by the error handler, normally it should raises <Target_conv>.Exception exception.

Sourceval of_mc_lazy_t : 'a encoder -> ('a, target) Open.mc_lazy_t encoder

typical <targe_type>_of_mc_lazy_t

Sourceval mc_lazy_t_of : 'a decoder -> ('a, target) Open.mc_lazy_t decoder

typical mc_lazy_t_of_<targe_type> The decoding is done lazily. Error at the lazy decoding is reported by the result monad.

Sourceval mc_fields_of : (target -> (string * target) list option) -> 'a decoder -> (string * 'a) list decoder

typical mc_fields_of_<targe_type>

Sourceval of_deconstr : (target -> 'a) -> 'a decoder

Convert a simple raw deconstr of type target -> 'a to 'a decoder. Error must be reported as Failure s. The other exceptions simply escape.

Sourceval of_hashtbl : (target encoder -> target list encoder) -> 'a encoder -> 'b encoder -> ('a, 'b) Hashtbl.t encoder
Sourceval hashtbl_of : (('a * 'b) decoder -> ('a * 'b) list decoder) -> 'a decoder -> 'b decoder -> ('a, 'b) Hashtbl.t decoder
Sourceval of_result : (target -> target) -> (target -> target) -> 'a encoder -> 'b encoder -> ('a, 'b) result encoder
Sourceval result_of : (target, target) result decoder -> 'a decoder -> 'b decoder -> ('a, 'b) result decoder
OCaml

Innovation. Community. Security.