|
52 | 52 | |
53 | 53 | [@@@ocaml.warning "-39-11-27"] |
54 | 54 | |
55 | | - let rec param_of_json a_of_json : Js.Json.t -> 'a param = |
56 | | - fun x -> a_of_json x |
| 55 | + let rec param_of_json a_of_json = |
| 56 | + (fun x -> a_of_json x : Js.Json.t -> 'a param) |
57 | 57 |
|
58 | 58 | let _ = param_of_json |
59 | 59 |
|
60 | 60 | [@@@ocaml.warning "-39-11-27"] |
61 | 61 |
|
62 | | - let rec param_to_json a_to_json : 'a param -> Js.Json.t = |
63 | | - fun x -> a_to_json x |
| 62 | + let rec param_to_json a_to_json = |
| 63 | + (fun x -> a_to_json x : 'a param -> Js.Json.t) |
64 | 64 | |
65 | 65 | let _ = param_to_json |
66 | 66 | end [@@ocaml.doc "@inline"] [@@merlin.hide] |
|
684 | 684 |
|
685 | 685 | [@@@ocaml.warning "-39-11-27"] |
686 | 686 |
|
687 | | - let rec c_of_json a_of_json : Js.Json.t -> 'a c = |
688 | | - fun x -> |
689 | | - if Js.Array.isArray x then |
690 | | - let array = (Obj.magic x : Js.Json.t array) in |
691 | | - let len = Js.Array.length array in |
692 | | - if Stdlib.( > ) len 0 then |
693 | | - let tag = Js.Array.unsafe_get array 0 in |
694 | | - if Stdlib.( = ) (Js.typeof tag) "string" then |
695 | | - let tag = (Obj.magic tag : string) in |
696 | | - if Stdlib.( = ) tag "C" then |
697 | | - if Stdlib.( <> ) len 2 then |
698 | | - Ppx_deriving_json_runtime.of_json_msg_error ~json:x |
699 | | - "expected a JSON array of length 2" |
700 | | - else `C (a_of_json (Js.Array.unsafe_get array 1)) |
701 | | - else |
702 | | - raise |
703 | | - (Ppx_deriving_json_runtime.Of_json_error |
704 | | - (Ppx_deriving_json_runtime.Unexpected_variant |
705 | | - "unexpected variant")) |
706 | | - else |
707 | | - Ppx_deriving_json_runtime.of_json_error ~json:x |
708 | | - "expected a non empty JSON array with element being a string" |
709 | | - else |
710 | | - Ppx_deriving_json_runtime.of_json_error ~json:x |
711 | | - "expected a non empty JSON array" |
712 | | - else |
713 | | - Ppx_deriving_json_runtime.of_json_error ~json:x |
714 | | - "expected a non empty JSON array" |
| 687 | + let rec c_of_json a_of_json = |
| 688 | + (fun x -> |
| 689 | + if Js.Array.isArray x then |
| 690 | + let array = (Obj.magic x : Js.Json.t array) in |
| 691 | + let len = Js.Array.length array in |
| 692 | + if Stdlib.( > ) len 0 then |
| 693 | + let tag = Js.Array.unsafe_get array 0 in |
| 694 | + if Stdlib.( = ) (Js.typeof tag) "string" then |
| 695 | + let tag = (Obj.magic tag : string) in |
| 696 | + if Stdlib.( = ) tag "C" then |
| 697 | + if Stdlib.( <> ) len 2 then |
| 698 | + Ppx_deriving_json_runtime.of_json_msg_error ~json:x |
| 699 | + "expected a JSON array of length 2" |
| 700 | + else `C (a_of_json (Js.Array.unsafe_get array 1)) |
| 701 | + else |
| 702 | + raise |
| 703 | + (Ppx_deriving_json_runtime.Of_json_error |
| 704 | + (Ppx_deriving_json_runtime.Unexpected_variant |
| 705 | + "unexpected variant")) |
| 706 | + else |
| 707 | + Ppx_deriving_json_runtime.of_json_error ~json:x |
| 708 | + "expected a non empty JSON array with element being a \ |
| 709 | + string" |
| 710 | + else |
| 711 | + Ppx_deriving_json_runtime.of_json_error ~json:x |
| 712 | + "expected a non empty JSON array" |
| 713 | + else |
| 714 | + Ppx_deriving_json_runtime.of_json_error ~json:x |
| 715 | + "expected a non empty JSON array" |
| 716 | + : Js.Json.t -> 'a c) |
715 | 717 | |
716 | 718 | let _ = c_of_json |
717 | 719 | |
718 | 720 | [@@@ocaml.warning "-39-11-27"] |
719 | 721 | |
720 | | - let rec c_to_json a_to_json : 'a c -> Js.Json.t = |
721 | | - fun x -> |
722 | | - match x with |
723 | | - | `C x_0 -> |
724 | | - (Obj.magic [| (Obj.magic "C" : Js.Json.t); a_to_json x_0 |] |
725 | | - : Js.Json.t) |
| 722 | + let rec c_to_json a_to_json = |
| 723 | + (fun x -> |
| 724 | + match x with |
| 725 | + | `C x_0 -> |
| 726 | + (Obj.magic [| (Obj.magic "C" : Js.Json.t); a_to_json x_0 |] |
| 727 | + : Js.Json.t) |
| 728 | + : 'a c -> Js.Json.t) |
726 | 729 |
|
727 | 730 | let _ = c_to_json |
728 | 731 | end [@@ocaml.doc "@inline"] [@@merlin.hide] |
|
983 | 986 |
|
984 | 987 | [@@@ocaml.warning "-39-11-27"] |
985 | 988 |
|
986 | | - let rec p2_of_json a_of_json b_of_json : Js.Json.t -> ('a, 'b) p2 = |
987 | | - fun x -> |
988 | | - if Js.Array.isArray x then |
989 | | - let array = (Obj.magic x : Js.Json.t array) in |
990 | | - let len = Js.Array.length array in |
991 | | - if Stdlib.( > ) len 0 then |
992 | | - let tag = Js.Array.unsafe_get array 0 in |
993 | | - if Stdlib.( = ) (Js.typeof tag) "string" then |
994 | | - let tag = (Obj.magic tag : string) in |
995 | | - if Stdlib.( = ) tag "A" then |
996 | | - if Stdlib.( <> ) len 2 then |
997 | | - Ppx_deriving_json_runtime.of_json_msg_error ~json:x |
998 | | - "expected a JSON array of length 2" |
999 | | - else A (a_of_json (Js.Array.unsafe_get array 1)) |
1000 | | - else if Stdlib.( = ) tag "B" then |
1001 | | - if Stdlib.( <> ) len 2 then |
1002 | | - Ppx_deriving_json_runtime.of_json_msg_error ~json:x |
1003 | | - "expected a JSON array of length 2" |
1004 | | - else B (b_of_json (Js.Array.unsafe_get array 1)) |
1005 | | - else |
1006 | | - Ppx_deriving_json_errors.of_json_error ~json:x |
1007 | | - "expected [\"B\", _] or [\"A\", _]" |
1008 | | - else |
1009 | | - Ppx_deriving_json_runtime.of_json_error ~json:x |
1010 | | - "expected a non empty JSON array with element being a string" |
1011 | | - else |
1012 | | - Ppx_deriving_json_runtime.of_json_error ~json:x |
1013 | | - "expected a non empty JSON array" |
1014 | | - else |
1015 | | - Ppx_deriving_json_runtime.of_json_error ~json:x |
1016 | | - "expected a non empty JSON array" |
| 989 | + let rec p2_of_json a_of_json b_of_json = |
| 990 | + (fun x -> |
| 991 | + if Js.Array.isArray x then |
| 992 | + let array = (Obj.magic x : Js.Json.t array) in |
| 993 | + let len = Js.Array.length array in |
| 994 | + if Stdlib.( > ) len 0 then |
| 995 | + let tag = Js.Array.unsafe_get array 0 in |
| 996 | + if Stdlib.( = ) (Js.typeof tag) "string" then |
| 997 | + let tag = (Obj.magic tag : string) in |
| 998 | + if Stdlib.( = ) tag "A" then |
| 999 | + if Stdlib.( <> ) len 2 then |
| 1000 | + Ppx_deriving_json_runtime.of_json_msg_error ~json:x |
| 1001 | + "expected a JSON array of length 2" |
| 1002 | + else A (a_of_json (Js.Array.unsafe_get array 1)) |
| 1003 | + else if Stdlib.( = ) tag "B" then |
| 1004 | + if Stdlib.( <> ) len 2 then |
| 1005 | + Ppx_deriving_json_runtime.of_json_msg_error ~json:x |
| 1006 | + "expected a JSON array of length 2" |
| 1007 | + else B (b_of_json (Js.Array.unsafe_get array 1)) |
| 1008 | + else |
| 1009 | + Ppx_deriving_json_errors.of_json_error ~json:x |
| 1010 | + "expected [\"B\", _] or [\"A\", _]" |
| 1011 | + else |
| 1012 | + Ppx_deriving_json_runtime.of_json_error ~json:x |
| 1013 | + "expected a non empty JSON array with element being a \ |
| 1014 | + string" |
| 1015 | + else |
| 1016 | + Ppx_deriving_json_runtime.of_json_error ~json:x |
| 1017 | + "expected a non empty JSON array" |
| 1018 | + else |
| 1019 | + Ppx_deriving_json_runtime.of_json_error ~json:x |
| 1020 | + "expected a non empty JSON array" |
| 1021 | + : Js.Json.t -> ('a, 'b) p2) |
1017 | 1022 |
|
1018 | 1023 | let _ = p2_of_json |
1019 | 1024 |
|
1020 | 1025 | [@@@ocaml.warning "-39-11-27"] |
1021 | 1026 |
|
1022 | | - let rec p2_to_json a_to_json b_to_json : ('a, 'b) p2 -> Js.Json.t = |
1023 | | - fun x -> |
1024 | | - match x with |
1025 | | - | A x_0 -> |
1026 | | - (Obj.magic [| (Obj.magic "A" : Js.Json.t); a_to_json x_0 |] |
1027 | | - : Js.Json.t) |
1028 | | - | B x_0 -> |
1029 | | - (Obj.magic [| (Obj.magic "B" : Js.Json.t); b_to_json x_0 |] |
1030 | | - : Js.Json.t) |
| 1027 | + let rec p2_to_json a_to_json b_to_json = |
| 1028 | + (fun x -> |
| 1029 | + match x with |
| 1030 | + | A x_0 -> |
| 1031 | + (Obj.magic [| (Obj.magic "A" : Js.Json.t); a_to_json x_0 |] |
| 1032 | + : Js.Json.t) |
| 1033 | + | B x_0 -> |
| 1034 | + (Obj.magic [| (Obj.magic "B" : Js.Json.t); b_to_json x_0 |] |
| 1035 | + : Js.Json.t) |
| 1036 | + : ('a, 'b) p2 -> Js.Json.t) |
1031 | 1037 |
|
1032 | 1038 | let _ = p2_to_json |
1033 | 1039 | end [@@ocaml.doc "@inline"] [@@merlin.hide] |
|
0 commit comments