@@ -13,29 +13,30 @@ let combine_error_msgs (js : json) (msg : string) (res : ('a, string) result) :
1313 ('a , string ) result =
1414 match res with
1515 | Ok x -> Ok x
16- | Error e -> Error (" [" ^ msg ^ " ]" ^ " failed on: " ^ show js ^ " \n\n " ^ e)
16+ | Error e ->
17+ Error (" [" ^ msg ^ " ]" ^ " failed on: " ^ to_string js ^ " \n\n " ^ e)
1718
1819let bool_of_json (ctx : 'ctx ) (js : json ) : (bool, string) result =
1920 match js with
2021 | `Bool b -> Ok b
21- | _ -> Error (" bool_of_json: not a bool: " ^ show js)
22+ | _ -> Error (" bool_of_json: not a bool: " ^ to_string js)
2223
2324let int_of_json (ctx : 'ctx ) (js : json ) : (int, string) result =
2425 match js with
2526 | `Int i -> Ok i
26- | _ -> Error (" int_of_json: not an int: " ^ show js)
27+ | _ -> Error (" int_of_json: not an int: " ^ to_string js)
2728
2829let char_of_json (ctx : 'ctx ) (js : json ) : (Uchar.t, string) result =
2930 match js with
3031 | `String c ->
3132 if String. length c > 4 then
32- Error (" char_of_json: stricly more than four bytes in: " ^ show js)
33+ Error (" char_of_json: stricly more than four bytes in: " ^ to_string js)
3334 else
3435 let uchar = String. get_utf_8_uchar c 0 in
3536 if Uchar. utf_decode_is_valid uchar then
3637 Ok (Uchar. utf_decode_uchar uchar)
37- else Error (" char_of_json: invalid UTF-8 character: " ^ show js)
38- | _ -> Error (" char_of_json: not a char: " ^ show js)
38+ else Error (" char_of_json: invalid UTF-8 character: " ^ to_string js)
39+ | _ -> Error (" char_of_json: not a char: " ^ to_string js)
3940
4041let rec of_json_list (a_of_json : 'ctx -> json -> ('a, string) result )
4142 (ctx : 'ctx ) (jsl : json list ) : ('a list, string) result =
@@ -54,7 +55,7 @@ let pair_of_json (a_of_json : 'ctx -> json -> ('a, string) result)
5455 let * a = a_of_json ctx a in
5556 let * b = b_of_json ctx b in
5657 Ok (a, b)
57- | _ -> Error (" pair_of_json failed on: " ^ show js)
58+ | _ -> Error (" pair_of_json failed on: " ^ to_string js)
5859
5960let triple_of_json (a_of_json : 'ctx -> json -> ('a, string) result )
6061 (b_of_json : 'ctx -> json -> ('b, string) result )
@@ -66,19 +67,19 @@ let triple_of_json (a_of_json : 'ctx -> json -> ('a, string) result)
6667 let * b = b_of_json ctx b in
6768 let * c = c_of_json ctx c in
6869 Ok (a, b, c)
69- | _ -> Error (" triple_of_json failed on: " ^ show js)
70+ | _ -> Error (" triple_of_json failed on: " ^ to_string js)
7071
7172let list_of_json (a_of_json : 'ctx -> json -> ('a, string) result ) (ctx : 'ctx )
7273 (js : json ) : ('a list, string) result =
7374 combine_error_msgs js " list_of_json"
7475 (match js with
7576 | `List jsl -> of_json_list a_of_json ctx jsl
76- | _ -> Error (" not a list: " ^ show js))
77+ | _ -> Error (" not a list: " ^ to_string js))
7778
7879let string_of_json (ctx : 'ctx ) (js : json ) : (string, string) result =
7980 match js with
8081 | `String str -> Ok str
81- | _ -> Error (" string_of_json: not a string: " ^ show js)
82+ | _ -> Error (" string_of_json: not a string: " ^ to_string js)
8283
8384let option_of_json (a_of_json : 'ctx -> json -> ('a, string) result )
8485 (ctx : 'ctx ) (js : json ) : ('a option, string) result =
@@ -105,4 +106,4 @@ let key_value_pair_of_json (a_of_json : 'ctx -> json -> ('a, string) result)
105106 let * a = a_of_json ctx a in
106107 let * b = b_of_json ctx b in
107108 Ok (a, b)
108- | _ -> Error (" key_value_pair_of_json failed on: " ^ show js)
109+ | _ -> Error (" key_value_pair_of_json failed on: " ^ to_string js)
0 commit comments