package ocf

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Ocf.WrapperSource

Sourcetype 'a t = {
  1. to_json : ?with_doc:bool -> 'a -> Yojson.Safe.t;
  2. from_json : ?def:'a -> Yojson.Safe.t -> 'a;
}
Sourceval make : (?with_doc:bool -> 'a -> Yojson.Safe.t) -> (?def:'a -> Yojson.Safe.t -> 'a) -> 'a t
Sourceval of_ok_error : (Yojson.Safe.t -> [ `Ok of 'a | `Error of 'b ]) -> Yojson.Safe.t -> 'a

of_ok_error f json applies f to json. If it returns `Ok x, then x is returned. Else invalid_value is called with the given json. This function is useful to wrap *_of_yojson functions generated by ppx_deriving_yojson.

Sourceval int : int t
Sourceval float : float t
Sourceval bool : bool t
Sourceval string : string t
Sourceval string_ : ('a -> string) -> (string -> 'a) -> 'a t
Sourceval list : 'a t -> 'a list t
Sourceval option : 'a t -> 'a option t
Sourceval pair : 'a t -> 'b t -> ('a * 'b) t
Sourceval triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
Sourcetype assocs = (string * Yojson.Safe.t) list
Sourceval string_map : fold:((string -> 'a -> assocs -> assocs) -> 'map -> assocs -> assocs) -> add:(string -> 'a -> 'map -> 'map) -> empty:'map -> 'a t -> 'map t

To create a map from strings to 'a. This will be stored in JSON as

 { foo: ...,  bar: ..., ... } 

Here foo and bar are the keys in the resulting map. The Map.S.fold, Map.S.add and Map.S.empty functions can be used for parameters fold, add and empty.