meta_conv / lib / internal.mli

(** You should not open this module, unless you are writing decoders/encoders for a new target data type. *)

open Types

(** { 6 Tools used by generated code } *)

val field_assoc_exn : 
  string                            (** type name *)
  -> string                         (** field name *)
  -> (string * 'target) list        (** record *)
  -> ('target Error.t -> 'host)     (** thrower *)
  -> ('host, 'target) Decoder.t_exn (** converter *)
  -> ('host, 'target) Decoder.t_exn

val field_assoc_optional_exn : 
  string                            (** type name *)
  -> string                         (** field name *)
  -> (string * 'target) list        (** record *)
  -> ('host, 'target) Decoder.t_exn (** converter *)
  -> ('host option, 'target) Decoder.t_exn

val filter_fields : 
  string list                  (** fields known in the type system *) 
  -> (string * 'target) list   (** the actual fields *) 
  -> (string * 'target) list   (** known fields *)
     * (string * 'target) list (** unknown fields *)

(** helper function for embded record field *)
val embeded_decoding_helper : 
  (string * 'target) list              (** secondary fields *)
  -> 'target                           (** the source target *) 
  -> ('host, 'target Error.t) Result.t (** sub decoder result *)
  -> ('host * (string * 'target) list, 'target Error.t) Result.t

(** { 6 Error decoders } *)

(** They are decoders but just fail *)

val tuple_arity_error : 
  int    (** expected *) 
  -> int (** actual *) 
  -> ('host, 'target) Decoder.t

val variant_arity_error : 
  string    (** type name *) 
  -> string (** constructor name *)
  -> int    (** expected *) 
  -> int    (** actual *) 
  -> ('host, 'target) Decoder.t

val variant_unknown_tag_error : 
  string    (** type name *)
  -> string (** tag name *) 
  -> ('host, 'target) Decoder.t

val primitive_decoding_failure : 
  string (** message *) 
  -> ('host, 'target) Decoder.t

val sub_decoders_failed_for_one_of : 
  string (** type name *)
  -> ('host, 'target) Decoder.t

(** { 6 Misc functions } *)

val list_filter_map : ('a -> 'b option) -> 'a list -> 'b list
(** List.map + List.filter *)

val list_mapi : (int -> 'a -> 'b) -> 'a list -> 'b list

val (~?) : 'a list option -> 'a list
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.