package ppx_meta_conv

  1. Overview
  2. Docs

If you want to write an instance of meta_conv implementation, you define the following primitive encoders and decoders at least.

Parameters

module A : Types.Min

Signature

include Types.Min with type target = A.target
type target = A.target
val format : Format.formatter -> target -> unit

The target must be printable.

module Constr : sig ... end
module Deconstr : sig ... end

Primitive ADT decoders. They may raise exceptions.

exception Exception of target Error.t

Exception for decoding error. We must declare here and not in a more general place, since the error contains target, and we cannot have polymorphic exceptions in OCaml.

type 'a encoder = ('a, target) Types.Encoder.t
type 'a decoder = ('a, target) Types.Decoder.t
type 'a decoder_exn = ('a, target) Types.Decoder.t_exn
module DeconstrDecoder : sig ... end

Auto generated decoders from Deconstr

val exn : 'a decoder -> 'a decoder_exn

Result monad decoder to decoder with runtime exception Exception.

val result : 'a decoder_exn -> 'a decoder

Any exception (including Exception) reported from decoder_exn is reported as Error

val throw : target Error.t -> 'exn

raises Exception

val catch : ('a -> 'b) -> 'a -> ('b, target Error.t) Result.t
val from_Ok : ('a, target Error.t) Result.t -> 'a

If the argument is Error e, raises Exception e.

val format_error : Format.formatter -> target Error.t -> unit

Format the error, without its trace

val format_full_error : Format.formatter -> target Error.t -> unit

Format the error, with its full trace

val format_with : ('host -> target) -> Format.formatter -> 'host -> unit

Format host data using its encoder

module Helper : sig ... end
OCaml

Innovation. Community. Security.