@@ -38,6 +38,8 @@ module Transform = struct
38
38
aux path;
39
39
Buffer. contents buf
40
40
41
+ let mk_path path = Ident (path_to_string path)
42
+
41
43
let mk_row_field (row_field : Types.row_field ) : oak =
42
44
match row_field with
43
45
| Rpresent _ -> Ident " row_field.Rpresent"
@@ -58,7 +60,7 @@ module Transform = struct
58
60
( " type_desc.Tconstr" ,
59
61
Tuple
60
62
[
61
- {name = " path" ; value = Ident (path_to_string path) };
63
+ {name = " path" ; value = mk_path path};
62
64
{name = " ts" ; value = mk_type_expr_list ts};
63
65
] )
64
66
| Tarrow (_ , t1 , t2 , _ ) ->
@@ -79,7 +81,7 @@ module Transform = struct
79
81
Tuple
80
82
[
81
83
{name = " type_expr" ; value = mk_type_desc t.desc};
82
- {name = " path" ; value = Ident (path_to_string path) };
84
+ {name = " path" ; value = mk_path path};
83
85
{
84
86
name = " ts" ;
85
87
value =
@@ -123,7 +125,7 @@ module Transform = struct
123
125
( " type_desc.Tpackage" ,
124
126
Tuple
125
127
[
126
- {name = " path" ; value = Ident (path_to_string path) };
128
+ {name = " path" ; value = mk_path path};
127
129
{name = " lids" ; value = List lids};
128
130
{name = " ts" ; value = mk_type_expr_list ts};
129
131
] )
@@ -157,7 +159,7 @@ module Transform = struct
157
159
value =
158
160
Tuple
159
161
[
160
- {name = " Path.t" ; value = Ident (path_to_string path) };
162
+ {name = " Path.t" ; value = mk_path path};
161
163
{
162
164
name = " fields" ;
163
165
value =
@@ -419,8 +421,30 @@ module Transform = struct
419
421
{name = " name" ; value = String type_.name};
420
422
{name = " attributes" ; value = mk_attribute_list type_.attributes};
421
423
]
424
+ let rec mk_structure (structure : SharedTypes.Module.structure ) : oak =
425
+ Record
426
+ [
427
+ {name = " name" ; value = String structure.name};
428
+ {name = " docstring" ; value = mk_string_list structure.docstring};
429
+ {name = " items" ; value = List (List. map mk_item structure.items)};
430
+ {name = " deprecated" ; value = mk_string_option structure.deprecated};
431
+ ]
432
+
433
+ and mk_module (module_ : SharedTypes.Module.t ) : oak =
434
+ match module_ with
435
+ | SharedTypes.Module. Ident path -> Application (" Ident" , mk_path path)
436
+ | SharedTypes.Module. Structure structure ->
437
+ Application (" Structure" , mk_structure structure)
438
+ | SharedTypes.Module. Constraint (t1 , t2 ) ->
439
+ Application
440
+ ( " Constraint" ,
441
+ Tuple
442
+ [
443
+ {name = " t1" ; value = mk_module t1};
444
+ {name = " t2" ; value = mk_module t2};
445
+ ] )
422
446
423
- let mk_item (item : SharedTypes.Module.item ) : oak =
447
+ and mk_item (item : SharedTypes.Module.item ) : oak =
424
448
let kind =
425
449
match item.kind with
426
450
| SharedTypes.Module. Value v ->
@@ -433,7 +457,14 @@ module Transform = struct
433
457
{name = " type" ; value = mk_type t};
434
458
{name = " rec_status" ; value = mk_rec_status rec_status};
435
459
] )
436
- | SharedTypes.Module. Module _ -> Ident " Module"
460
+ | SharedTypes.Module. Module m ->
461
+ Application
462
+ ( " Module" ,
463
+ Record
464
+ [
465
+ {name = " type_" ; value = mk_module m.type_};
466
+ {name = " isModuleType" ; value = mk_bool m.isModuleType};
467
+ ] )
437
468
in
438
469
Record
439
470
[
@@ -443,15 +474,6 @@ module Transform = struct
443
474
{name = " deprecated" ; value = mk_string_option item.deprecated};
444
475
]
445
476
446
- let mk_structure (structure : SharedTypes.Module.structure ) : oak =
447
- Record
448
- [
449
- {name = " name" ; value = String structure.name};
450
- {name = " docstring" ; value = mk_string_list structure.docstring};
451
- {name = " items" ; value = List (List. map mk_item structure.items)};
452
- {name = " deprecated" ; value = mk_string_option structure.deprecated};
453
- ]
454
-
455
477
let mk_file (file : SharedTypes.File.t ) : oak =
456
478
Record
457
479
[
0 commit comments