package ocaml-protoc-plugin

  1. Overview
  2. Docs
Plugin for protoc protobuf compiler to generate ocaml definitions from a .proto file

Install

Dune Dependency

Authors

Maintainers

Sources

1.0.0.tar.gz
md5=278461dfca05f428e54abddfdf229471
sha512=b54528f0079c3d38d746ba97e48530bc87edfa684bc814623c450ee65502c6d16b9ae304c6ea6e19ff0ca84c454601a367abd35b295abf5b727bc702ff792716

doc/src/ocaml-protoc-plugin.protobuf/result.ml.html

Source file result.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(** This module provides result type and functions for compatibility
 * with OCaml 4.06 *)

type error =
  [ `Premature_end_of_input
  | `Unknown_field_type of int
  | `Wrong_field_type of string * Field.t
  | `Illegal_value of string * Field.t
  | `Not_implemented
  | `Unknown_enum_value of int
  | `Oneof_missing
  | `Required_field_missing ]

let show_error = function
  | `Premature_end_of_input -> "`Premature_end_of_input"
  | `Unknown_field_type i -> Printf.sprintf "`Unknown_field_type: %d" i
  | `Wrong_field_type (s, f) -> Printf.sprintf "`Wrong_field_type: %s - %s" s (Field.show f)
  | `Illegal_value (s, f) -> Printf.sprintf "`Illegal_value: %s - %s" s (Field.show f)
  | `Not_implemented-> "`Not_implemente"
  | `Unknown_enum_value i -> Printf.sprintf "`Unknown_enum_value: %d" i
  | `Oneof_missing-> "`Oneof_missin"
  | `Required_field_missing -> "`Required_field_missing"

type 'a t = ('a, error) result

let ( >>| ) v f = match v with Ok x -> Ok (f x) | Error err -> Error err
let ( >>= ) v f = match v with Ok x -> f x | Error err -> Error err

(* Extra functions (from Base) *)

let return x = Ok x
let fail x = Error x
OCaml

Innovation. Community. Security.