Debian Codegraph @

expander/ppx_let_expander.mli

raw symbols SCIP
1 open Ppxlib
2
3 module Extension_kind : sig
4 type t =
5 { do_open : bool
6 ; collapse_binds : bool
7 }
8
9 (* let%bind, let%map, etc. *)
10 val default : t
11
12 (* let%bind_open, let%map_open, etc. *)
13 val default_open : t
14
15 (* let%bindn, let%mapn, etc. *)
16 val n : t
17
18 (* let%bindn_open, let%mapn_open, etc. *)
19 val n_open : t
20 end
21
22 module type Ext = sig
23 (* The base string of all the related extensions. For example, if the value
24 is "bind", then other extensions will include "bind_open", "bindn", and
25 "bindn_open" - all of which start with "bind" *)
26 val name : string
27 val with_location : bool
28
29 (* When true, prevent_tail_call will keep the resulting
30 function application from being in tail position by introducing a local
31 variable. This is useful when working in with locals, and was added in order to
32 allow ppx_bonsai to transform
33
34 {[
35 let%sub a = foo in
36 a
37 ]}
38
39 into
40
41 {[ ((sub foo ~f:(fun a -> a))[@nontail]) ]}
42
43 instead of
44
45 {[ sub foo ~f:(fun a -> a) ]} *)
46 val prevent_tail_call : bool
47
48 (* Called before each expansion to ensure that the expression being expanded
49 is supported. *)
50 val disallow_expression : Extension_kind.t -> expression_desc -> (unit, string) Result.t
51
52 (* Called when expanding a let-binding (and indirectly, when expanding a
53 match-expression) to destructure [rhs]. The resulting expression should
54 make each variable in [lhs] available for use in [body]. If the result is
55 [None], then no special destructuring is necessary. *)
56 val destruct
57 : assume_exhaustive:bool
58 -> loc:location
59 -> modul:longident loc option
60 -> lhs:pattern
61 -> rhs:expression
62 -> body:expression
63 -> expression option
64
65 (* Expands any match%[name] expressions. It is also used when expanding
66 if%[name]. *)
67 val expand_match
68 : loc:location
69 -> modul:longident loc option
70 -> locality:[ `local | `global ]
71 -> expression
72 -> case list
73 -> expression
74
75 (* [expand] is the function that normally expands let%[name]. [wrap_expansion] can be
76 used to change the parameters given to [expand] and can also tranform the output of
77 [expand]. *)
78 val wrap_expansion
79 : loc:location
80 -> modul:longident loc option
81 -> value_binding list
82 -> expression
83 -> expand:(loc:location -> value_binding list -> expression -> expression)
84 -> expression
85 end
86
87 (* A trivial implementation of [Ext.wrap_expansion] that does nothing to change
88 the expansion behavior. *)
89 val wrap_expansion_identity
90 : loc:location
91 -> modul:longident loc option
92 -> value_binding list
93 -> expression
94 -> expand:(loc:location -> value_binding list -> expression -> expression)
95 -> expression
96
97 type t = (module Ext)
98
99 val ext_full_name : t -> locality:[ `local | `global ] -> Extension_kind.t -> label
100 val bind : t
101 val map : t
102 val variables_of : label loc list Ast_traverse.fold
103
104 module Map : sig
105 val name : string
106 val with_location : bool
107 end
108
109 val eoperator : loc:location -> modul:longident loc option -> label -> expression
110
111 val expand_match
112 : t
113 -> extension_kind:Extension_kind.t
114 -> loc:location
115 -> modul:longident loc option
116 -> locality:[ `local | `global ]
117 -> expression
118 -> case list
119 -> expression
120
121 val maybe_destruct
122 : destruct:
123 (assume_exhaustive:bool
124 -> loc:location
125 -> modul:'a
126 -> lhs:pattern
127 -> rhs:expression
128 -> body:expression
129 -> expression option)
130 -> loc:location
131 -> modul:'a
132 -> locality:[ `local | `global ]
133 -> lhs:pattern
134 -> body:expression
135 -> expression
136
137 val bind_apply
138 : ?fn_label:string (** default: "f" *)
139 -> prevent_tail_call:bool
140 -> op_name:label
141 -> loc:location
142 -> modul:longident loc option
143 -> with_location:bool
144 -> arg:expression
145 -> fn:expression
146 -> unit
147 -> expression
148
149 val qualified_return
150 : loc:location
151 -> modul:longident loc option
152 -> expression
153 -> expression
154
155 val expand
156 : t
157 -> Extension_kind.t
158 -> modul:longident loc option
159 -> locality:[ `local | `global ]
160 -> expression
161 -> expression
162
163 val do_not_enter_value : value_binding -> value_binding
164 val nontail : loc:location -> expression -> expression