6 country
: string option;
9 (* [@@deriving sexp] *)
11 (* https://gitlab.inria.fr/bmontagu/sexp_decode
12 via https://discuss.ocaml.org/t/combinator-library-for-extracting-data-for-s-exps/10153/5 *)
14 let open Sexp_decode
in
15 Logr.info
(fun m
-> m
"test_sexp_a");
16 let entry_decoder : entry decoder
=
18 @@ let* name
= field
"name" atom
in
19 let* country
= maybe
@@ field
"country" atom
in
20 let+ email
= maybe
@@ field
"email" atom
in
21 { name
; country
; email
} in
22 let address_book_decoder (* : address_book decoder *) = list
entry_decoder in
23 let _r = run
address_book_decoder (Atom
"a") in
24 Assrt.equals_string __LOC__
"a" "a";
27 module D
= Decoders_ezjsonm.Decode
29 (* https://discuss.ocaml.org/t/combinator-library-for-extracting-data-for-s-exps/10153 *)
30 let test_decoders () =
32 let _announce : entry decoder
=
33 let* _
= field
"type" string
34 and* name
= field
"actor" string in
35 succeed
({name
; country
= None
; email
= None
;})
37 let r = (D.decode_string
(_announce ) "((type "") (actor uhu))")
40 |> Assrt.equals_string __LOC__
"u"
43 Unix.chdir
"../../../test/";