package ppx_typed_fields

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file nothing_generator.ml

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
open Ppxlib

(* The structure items will be inserted after the type type
   definitions and before any other items.*)
let extra_structure_items_to_insert loc =
  let open (val Ast_builder.make loc) in
  [ [%stri
      let unreachable_code = function
        | (_ : _ typed__t) -> .
      ;;]
  ]
;;

let generate_constructor_declarations ~loc:_ ~elements_to_convert:_ ~core_type_params:_ =
  []
;;

let names_list ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr []]
;;

let name_function_body ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr unreachable_code]
;;

let path_function_body ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr unreachable_code]
;;

let ord_function_body ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr unreachable_code]
;;

let get_function_body ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr unreachable_code]
;;

let create_function_body ~loc ~constructor_declarations:_ =
  let open (val Ast_builder.make loc) in
  [%expr unreachable_code]
;;

let type_ids ~loc:_ ~elements_to_convert:_ ~core_type_params:_ = []

let type_id_function_body ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr unreachable_code]
;;

let sexp_of_t_body ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr
    match packed with
    | (_ : t) -> .]
;;

let all_body ~loc ~constructor_declarations:_ =
  let open (val Ast_builder.make loc) in
  [%expr []]
;;

let pack_body ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr unreachable_code]
;;

let t_of_sexp_body ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [%expr
    Base.raise_s
      (Sexplib.Sexp.List
         [ Sexplib.Sexp.Atom "Nothing has no constructors, so cannot convert to variant."
         ; sexp
         ])]
;;

let which_function_body ~loc ~elements_to_convert:_ ~number_of_params =
  let open (val Ast_builder.make loc) in
  match number_of_params with
  | 0 ->
    [%expr
      function
      | (_ : derived_on) -> .]
  | _ ->
    [%expr
      function
      | (_ : _ derived_on) -> .]
;;

let deep_functor_signature ~loc ~elements_to_convert:_ ~base_module_type =
  let open (val Ast_builder.make loc) in
  psig_module
    (module_declaration ~name:(Some "Deep" |> Located.mk) ~type_:base_module_type)
;;

let deep_functor_structure ~loc ~elements_to_convert:_ ~module_expression =
  let open (val Ast_builder.make loc) in
  pstr_module (module_binding ~name:(Some "Deep" |> Located.mk) ~expr:module_expression)
;;

(**
   Generates the full depth module of a structure, e.g.
   [
   module Constr1_subproduct = [%typed_field ...];
   module Name_subproduct = [%typed_field ...];
   ...;
   include Deep (Constr1_subproduct) (Name_subproduct)
   ]
*)
let full_depth_module ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [ [%stri include Deep] ]
;;

(**
   Generates the full_depth module's signature.
   e.g.

   [
   module Constr1_subproduct : module type of [%typed_field ...];
   module Name_subproduct : module type of [%typed_field ...];
   ...;
   include module type of Deep
   (Constr1_subproduct)
   (Name_subproduct)
   ]
*)
let full_depth_signature ~loc ~elements_to_convert:_ =
  let open (val Ast_builder.make loc) in
  [ [%sigi: include module type of Deep] ]
;;

(*  Generates the signature for the singleton modules sent to Shallow

    [
    module Singleton_for_t_1 : sig ... end;
    module Singleton_for_t_2 : sig ... end;
    ...

    ]
*)
let singleton_modules_signatures ~loc:_ ~elements_to_convert:_ = []

(*  Generates the structure for the sigleton modules sent to Shallow

    [
    module Singleton_for_t_1 = struct ... end;
    module Singleton_for_t_2 = struct ... end;
    ...

    ]
*)
let singleton_modules_structures ~loc:_ ~elements_to_convert:_ = []