Skip to content

Commit 883beca

Browse files
committed
Fix ppx_register_even
1 parent 18f73e1 commit 883beca

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

src/lib/ppx_register_event/register_event.ml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
open Core_kernel
22
open Ppxlib
3-
module Conv_to_ppx_deriving =
4-
Migrate_parsetree.Convert (Selected_ast) (Migrate_parsetree.OCaml_current)
5-
module Conv_from_ppx_deriving =
6-
Migrate_parsetree.Convert (Migrate_parsetree.OCaml_current) (Selected_ast)
73

84
let deriver = "register_event"
95

106
let digest s = Md5.digest_string s |> Md5.to_hex
117

128
let checked_interpolations_statically ~loc msg label_names =
139
match msg with
14-
| { pexp_desc = Pexp_constant (Pconst_string (s, _)); _ } -> (
10+
| { pexp_desc = Pexp_constant (Pconst_string (s, _, _)); _ } -> (
1511
(* check that every interpolation point $foo in msg has a matching label;
1612
OK to have extra labels not mentioned in message
1713
*)
@@ -107,42 +103,34 @@ let generate_loggers_and_parsers ~loc:_ ~path ty_ext msg_opt =
107103
let event_name = String.lowercase ctor in
108104
let event_path = path ^ "." ^ ctor in
109105
let split_path = String.split path ~on:'.' in
110-
let to_yojson x =
111-
Conv_from_ppx_deriving.copy_expression
112-
@@ Ppx_deriving_yojson.ser_expr_of_typ
113-
@@ Conv_to_ppx_deriving.copy_core_type x
106+
let to_yojson = Ppx_deriving_yojson.ser_expr_of_typ
114107
in
115-
let of_yojson ~path x =
116-
Conv_from_ppx_deriving.copy_expression
117-
@@ Ppx_deriving_yojson.desu_expr_of_typ ~path
118-
@@ Conv_to_ppx_deriving.copy_core_type x
108+
let of_yojson = Ppx_deriving_yojson.desu_expr_of_typ
119109
in
120110
let elist ~f l = elist (List.map ~f l) in
121111
let record_pattern =
122-
let open Ast_helper.Pat in
123112
let arg =
124113
if has_record_arg then
125114
let fields =
126115
List.map label_names ~f:(fun label ->
127116
(Located.mk (Lident label), pvar label) )
128117
in
129-
Some (record fields Closed)
118+
Some (ppat_record fields Closed)
130119
else None
131120
in
132-
construct (Located.mk (Lident ctor)) arg
121+
ppat_construct (Located.mk (Lident ctor)) arg
133122
in
134123
let record_expr =
135-
let open Ast_helper.Exp in
136124
let arg =
137125
if has_record_arg then
138126
let fields =
139127
List.map label_names ~f:(fun label ->
140128
(Located.mk (Lident label), evar label) )
141129
in
142-
Some (record fields None)
130+
Some (pexp_record fields None)
143131
else None
144132
in
145-
construct (Located.mk (Lident ctor)) arg
133+
pexp_construct (Located.mk (Lident ctor)) arg
146134
in
147135
let stris =
148136
[ [%stri
@@ -165,9 +153,7 @@ let generate_loggers_and_parsers ~loc:_ ~path ty_ext msg_opt =
165153
elist label_decls
166154
~f:(fun { pld_name = { txt = name; _ }; pld_type; _ }
167155
->
168-
Conv_from_ppx_deriving.copy_expression
169-
@@ Ppx_deriving_yojson.wrap_runtime
170-
@@ Conv_to_ppx_deriving.copy_expression
156+
Ppx_deriving_yojson.wrap_runtime
171157
@@ [%expr
172158
[%e estring name]
173159
, [%e to_yojson pld_type] [%e evar name]] )] )
@@ -182,9 +168,7 @@ let generate_loggers_and_parsers ~loc:_ ~path ty_ext msg_opt =
182168
[%e
183169
List.fold_right label_decls
184170
~f:(fun { pld_name = { txt = name; _ }; pld_type; _ } acc ->
185-
Conv_from_ppx_deriving.copy_expression
186-
@@ Ppx_deriving_yojson.wrap_runtime
187-
@@ Conv_to_ppx_deriving.copy_expression
171+
Ppx_deriving_yojson.wrap_runtime
188172
@@ [%expr
189173
match
190174
Core_kernel.Map.find args_list [%e estring name]

0 commit comments

Comments
 (0)