@@ -28,8 +28,7 @@ open Ppxlib
28
28
let string_of_expression e =
29
29
Format. set_margin 1000 ;
30
30
Format. set_max_indent 0 ;
31
- let ans = Format. asprintf " %a" Pprintast. expression e in
32
- ans
31
+ Format. asprintf " %a" Pprintast. expression e
33
32
;;
34
33
35
34
let name = " tester"
@@ -42,23 +41,25 @@ let () =
42
41
(pstr_eval
43
42
(pexp_apply
44
43
__
45
- ((nolabel ** __) ^:: (nolabel ** __) ^:: (nolabel ** __) ^:: (nolabel ** __) ^:: nil))
44
+ ((nolabel ** __) ^:: (nolabel ** __) ^:: (nolabel ** __) ^:: (nolabel ** __) ^:: nil
45
+ |> map2 ~f: (fun a b -> [ a; b ])
46
+ ||| ((nolabel ** __) ^:: (nolabel ** __) ^:: nil |> map0 ~f: [] )))
46
47
nil
47
48
^:: nil)
48
49
in
49
50
[ Extension. declare
50
51
name
51
52
Extension.Context. Expression
52
53
pattern
53
- (fun ~loc ~path :_ runner reifier shower n realtion ->
54
+ (fun ~loc ~path :_ runner reifier_shower n relation ->
54
55
let open Ppxlib.Ast_builder.Default in
55
56
let count =
56
57
let rec helper acc e =
57
58
match e.pexp_desc with
58
59
| Pexp_fun (_ , _ , _ , body ) -> helper (1 + acc) body
59
60
| _ -> acc
60
61
in
61
- helper 0 realtion
62
+ helper 0 relation
62
63
in
63
64
let middle =
64
65
match count with
@@ -70,13 +71,13 @@ let () =
70
71
| _ -> failwith (Printf. sprintf " 5 and more arguments are not supported" )
71
72
in
72
73
let last =
73
- let s = string_of_expression @@ realtion in
74
+ let s = string_of_expression relation in
74
75
let open Ppxlib.Ast_builder.Default in
75
- [% expr [% e pexp_constant ~loc (Pconst_string (s, loc, None ))], [% e realtion ]]
76
+ [% expr [% e pexp_constant ~loc (Pconst_string (s, loc, None ))], [% e relation ]]
76
77
in
77
78
pexp_apply ~loc runner
78
79
@@ List. map (fun e -> Nolabel , e)
79
- @@ List. concat [ [ reifier; shower; n ]; middle; [ last ] ])
80
+ @@ List. concat [ reifier_shower @ [ n ]; middle; [ last ] ])
80
81
]
81
82
in
82
83
Ppxlib.Driver. register_transformation ~extensions name
0 commit comments