1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
open Base
open Ppxlib
let lident_of_list = function
| [] -> failwith "Bad argument: lident_of_list"
| s :: tl -> List.fold_left tl ~init:(Lident s) ~f:(fun acc x -> Ldot (acc, x))
;;
let =
List.map ~f:(fun (typ, _) ->
match typ.ptyp_desc with
| Ptyp_var s -> s
| _ ->
failwith
(Caml.Format.asprintf "Don't know what to do with %a" Pprintast.core_type typ))
;;
open Ppxlib.Ast_builder.Default
open Ppxlib.Ast_helper
module Located = struct
include Located
let map_loc ~f l = { l with txt = f l.txt }
let sprintf ~loc fmt = Caml.Format.kasprintf (mk ~loc) fmt
end
module Exp = struct
include Exp
let mytuple ~loc ?(attrs = []) = function
| [] -> failwith "Bad argument: mytuple"
| [ x ] -> x
| xs -> tuple ~loc ~attrs xs
;;
let apply ~loc f = function
| [] -> f
| xs -> apply ~loc f (List.map ~f:(fun e -> Nolabel, e) xs)
;;
let lident ~loc l = pexp_ident ~loc (Located.mk ~loc (lident l))
let ident ~loc lident = pexp_ident ~loc (Located.mk ~loc lident)
end
let lident_of_list = function
| [] -> failwith "Bad argument: lident_of_list"
| s :: tl -> List.fold_left tl ~init:(Lident s) ~f:(fun acc x -> Ldot (acc, x))
;;