Skip to content

Commit 1d622d6

Browse files
committed
Misc: do not use @@ operator
1 parent 65aef75 commit 1d622d6

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

lib/ppx/ppx_js.cppo.ml

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ let random_tvar () =
5151

5252
let inside_Js = lazy
5353
(try
54-
Filename.basename @@ Filename.chop_extension !Location.input_name = "js"
54+
Filename.basename (Filename.chop_extension !Location.input_name) = "js"
5555
with Invalid_argument _ -> false)
5656

5757
module Js = struct
5858

5959
let type_ ?loc s args =
6060
if Lazy.force inside_Js
6161
then Typ.constr ?loc (lid s) args
62-
else Typ.constr ?loc (lid @@ "Js."^s) args
62+
else Typ.constr ?loc (lid ("Js."^s)) args
6363

6464
#if OCAML_VERSION < (4, 03, 0)
6565
let nolabel = ""
@@ -70,19 +70,19 @@ module Js = struct
7070
let unsafe ?loc s args =
7171
let args = List.map (fun x -> nolabel,x) args in
7272
if Lazy.force inside_Js
73-
then Exp.(apply ?loc (ident ?loc @@ lid ?loc ("Unsafe."^s)) args)
74-
else Exp.(apply ?loc (ident ?loc @@ lid ?loc ("Js.Unsafe."^s)) args)
73+
then Exp.(apply ?loc (ident ?loc (lid ?loc ("Unsafe."^s))) args)
74+
else Exp.(apply ?loc (ident ?loc (lid ?loc ("Js.Unsafe."^s))) args)
7575

7676
let fun_ ?loc s args =
7777
let args = List.map (fun x -> nolabel,x) args in
7878
if Lazy.force inside_Js
79-
then Exp.(apply ?loc (ident ?loc @@ lid ?loc s) args)
80-
else Exp.(apply ?loc (ident ?loc @@ lid ?loc ("Js."^s)) args)
79+
then Exp.(apply ?loc (ident ?loc (lid ?loc s)) args)
80+
else Exp.(apply ?loc (ident ?loc (lid ?loc ("Js."^s))) args)
8181

8282
end
8383

8484

85-
let fresh_type loc = Typ.var ~loc @@ random_tvar ()
85+
let fresh_type loc = Typ.var ~loc (random_tvar ())
8686

8787
let unescape lab =
8888
assert (lab <> "");
@@ -146,22 +146,22 @@ let method_call ~loc obj meth args =
146146
let args =
147147
List.map
148148
(fun (l,e) ->
149-
let (ev, pv) = mk_id ~loc:e.pexp_loc @@ random_var () in
149+
let (ev, pv) = mk_id ~loc:e.pexp_loc (random_var ()) in
150150
(e, ev, pv, (l, fresh_type obj.pexp_loc)))
151151
args in
152152
let ret_type = fresh_type obj.pexp_loc in
153153
let method_type =
154-
arrows (List.map (fun (_,_,_,x) -> x) args) @@ Js.type_ "meth" [ret_type] in
155-
let e_obj, p_obj = mk_id ~loc:obj.pexp_loc @@ "jsoo_self" in
156-
let e_res, p_res = mk_id ~loc:obj.pexp_loc @@ "jsoo_res" in
154+
arrows (List.map (fun (_,_,_,x) -> x) args) (Js.type_ "meth" [ret_type]) in
155+
let e_obj, p_obj = mk_id ~loc:obj.pexp_loc "jsoo_self" in
156+
let e_res, p_res = mk_id ~loc:obj.pexp_loc "jsoo_res" in
157157
let meth_call =
158158
Js.unsafe "meth_call" [
159159
e_obj ;
160-
str @@ unescape meth ;
161-
Exp.array @@
162-
List.map
163-
(fun (_, ev, _, _) -> Js.unsafe "inject" [ev])
164-
args
160+
str (unescape meth) ;
161+
Exp.array
162+
(List.map
163+
(fun (_, ev, _, _) -> Js.unsafe "inject" [ev])
164+
args)
165165
]
166166
in
167167

@@ -187,10 +187,10 @@ let new_object constr args =
187187
let obj_type = Js.type_ "t" [fresh_type constr.loc] in
188188
let constr_fun_type = arrows (List.map snd args) obj_type in
189189
let args =
190-
Exp.array @@
191-
List.map
192-
(fun (e, (_l,t)) -> Js.unsafe "inject" [Exp.constraint_ e t])
193-
args
190+
Exp.array
191+
(List.map
192+
(fun (e, (_l,t)) -> Js.unsafe "inject" [Exp.constraint_ e t])
193+
args)
194194
in
195195
let x = random_var () in
196196
let constr =
@@ -253,7 +253,7 @@ let preprocess_literal_object mappper fields =
253253
"This field is not valid inside a js literal object."
254254
in
255255
try
256-
`Fields (List.rev @@ snd @@ List.fold_left f (S.empty, []) fields)
256+
`Fields (List.rev (snd (List.fold_left f (S.empty, []) fields)))
257257
with Location.Error error -> `Error (extension_of_error error)
258258

259259
(** Desugar something like this:
@@ -310,8 +310,7 @@ let literal_object self_id fields =
310310
annotate_body types ret_ty body)
311311
}
312312
| [], body -> Exp.constraint_ ~loc:body.pexp_loc body ret_ty
313-
| _ -> raise @@
314-
Invalid_argument "Inconsistent number of arguments"
313+
| _ -> raise (Invalid_argument "Inconsistent number of arguments")
315314
in
316315

317316
let create_value = function
@@ -331,18 +330,19 @@ let literal_object self_id fields =
331330
let values = List.map create_value fields in
332331

333332
let make_obj =
334-
funs (List.map (fun (name,_exp) -> pvar name) values) @@
335-
Exp.constraint_
336-
(Js.unsafe
337-
"obj"
338-
[Exp.array (
339-
List.map
340-
(fun (name, _exp) ->
341-
tuple [str name ; Js.unsafe "inject" [evar name] ]
342-
)
343-
values
344-
)])
345-
(Typ.alias (Js.type_ "t" [obj_type]) self_type)
333+
funs
334+
(List.map (fun (name,_exp) -> pvar name) values)
335+
(Exp.constraint_
336+
(Js.unsafe
337+
"obj"
338+
[Exp.array (
339+
List.map
340+
(fun (name, _exp) ->
341+
tuple [str name ; Js.unsafe "inject" [evar name] ]
342+
)
343+
values
344+
)])
345+
(Typ.alias (Js.type_ "t" [obj_type]) self_type))
346346
in
347347

348348
let value_declaration =
@@ -351,7 +351,7 @@ let literal_object self_id fields =
351351
( Vb.mk (pvar "make_obj") make_obj ::
352352
List.map (fun (name, exp) -> Vb.mk (pvar name) exp) values
353353
)
354-
(app (evar "make_obj") @@ List.map (fun (name,_) -> evar name) values)
354+
(app (evar "make_obj") (List.map (fun (name,_) -> evar name) values))
355355
in
356356

357357
value_declaration
@@ -372,7 +372,7 @@ let js_mapper _args =
372372
let new_expr =
373373
[%expr
374374
let [%p p_obj] = [%e obj] in
375-
let [%p p_res] = [%e Js.unsafe "get" [e_obj ; str @@ unescape meth]] in
375+
let [%p p_res] = [%e Js.unsafe "get" [e_obj ; str (unescape meth)]] in
376376
[%e
377377
constrain_types
378378
e_obj
@@ -404,7 +404,7 @@ let js_mapper _args =
404404
[]
405405
]
406406
in
407-
[%e Js.unsafe ~loc:expr.pexp_loc "set" [ e_obj ; str @@ unescape meth ; e_value]]
407+
[%e Js.unsafe ~loc:expr.pexp_loc "set" [ e_obj ; str (unescape meth) ; e_value]]
408408
]
409409
in
410410
mapper.expr mapper { new_expr with pexp_attributes }

lib/syntax/pa_js.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ module Make (Syntax : Sig.Camlp4Syntax) = struct
303303
(<:expr< fun $pat$ -> $body$ >>) ->
304304
<:expr< fun ($pat$ : $ty$) -> $annotate_body types ret_ty body$ >>
305305
| [], body -> <:expr< ($body$ : $ret_ty$) >>
306-
| _ -> raise @@
307-
Invalid_argument "Inconsistent number of arguments"
306+
| _ -> raise (Invalid_argument "Inconsistent number of arguments")
308307
in
309308

310309
let create_value = function

0 commit comments

Comments
 (0)