File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Ppx Protocol Conv
22Ppx protocol conv (de)serializers using deriving, which allows for
3- plugable (de)serializers. [ Api] ( https://andersfugmann.github.io/ppx_protocol_conv ) .
3+ plugable
4+ (de)serializers. [ Api] ( https://andersfugmann.github.io/ppx_protocol_conv ) .
5+
6+ This page contains an simple overview of functionality provided. More
7+ information is available in the [ wiki pages] ( https://github.com/andersfugmann/ppx_protocol_conv/wiki )
48
59[ ![ Build Status] ( https://travis-ci.org/andersfugmann/ppx_protocol_conv.svg?branch=master )] ( https://travis-ci.org/andersfugmann/ppx_protocol_conv )
610
@@ -44,10 +48,12 @@ type b = A of int
4448will generate the functions:
4549``` ocaml
4650val a_to_json: a -> Json.t
47- val a_of_json: Json.t -> a
51+ val a_of_json_exn: Json.t -> a
52+ val a_of_json: Json.t -> (a, exn) result
4853
4954val b_to_json: a -> Json.t
50- val b_of_json: Json.t -> a
55+ val b_of_json_exn: Json.t -> a
56+ val b_of_json: Json.t -> (b, exn) result
5157```
5258
5359``` ocaml
@@ -103,4 +109,3 @@ Submissions of new drivers are more than welcome.
103109* Generalised algebraic datatypes
104110* Extensible types
105111* Extensible polymorphic variants
106- * nativeint
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ module type Test = sig
1818 val t : unit -> t
1919 val to_json : t -> Json .t
2020 val to_yojson : t -> Yojson.Safe .json
21- val of_json : Json .t -> t
21+ val of_json : Json .t -> t Protocol_conv.Runtime .or_error
2222 val of_yojson : Yojson.Safe .json -> t Ppx_deriving_yojson_runtime .error_or
2323end
2424
@@ -129,11 +129,13 @@ let e () = match Random.int 20 with
129129
130130module Test_enum : Test = struct
131131 let name = " Enum"
132- type t = A0 | A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19
132+ type u = A0 | A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19
133+ and t = u list
133134 [@@ deriving protocol ~driver: (module Json ), yojson ]
134- let t () = match Random. int 20 with
135+ let u () = match Random. int 20 with
135136 | 0 -> A0 | 1 -> A1 | 2 -> A2 | 3 -> A3 | 4 -> A4 | 5 -> A5 | 6 -> A6 | 7 -> A7 | 8 -> A8 | 9 -> A9 | 10 -> A10
136137 | 11 -> A11 | 12 -> A12 | 13 -> A13 | 14 -> A14 | 15 -> A15 | 16 -> A16 | 17 -> A17 | 18 -> A18 | 19 -> A19 | _ -> failwith " e"
138+ let t () = list ~length: 10 u ()
137139end
138140
139141type f = d * e
You can’t perform that action at this time.
0 commit comments