package ppx_deriving_yojson

  1. Overview
  2. Docs
JSON codec generator for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

ppx_deriving_yojson-v3.6.1.tbz
sha256=712ee9207c70dd144e72cd689bee2d2beb120b804e77c74ec6f7b843a88944e6
sha512=d8c828902b8441f73e08fc03e2173ce81a09cccfe091471fbcffe098b2272739b98a05e8308016da3efeb3d4d1abd7d941bfaac42c85961ea40915ddce526577

doc/src/ppx_deriving_yojson.runtime/ppx_deriving_yojson_runtime.ml.html

Source file ppx_deriving_yojson_runtime.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
include Ppx_deriving_runtime

let (>>=) x f =
  match x with Result.Ok x -> f x | (Result.Error _) as x -> x

let (>|=) x f =
  x >>= fun x -> Result.Ok (f x)

let rec map_bind f acc xs =
  match xs with
  | x :: xs -> f x >>= fun x -> map_bind f (x :: acc) xs
  | [] -> Result.Ok (List.rev acc)

type 'a error_or = ('a, string) Result.result

(** [safe_map f l] returns the same value as [List.map f l], but
    computes it tail-recursively so that large list lengths don't
    cause a stack overflow *)
let safe_map f l = List.rev (List.rev_map f l)
OCaml

Innovation. Community. Security.