···11+This repository contains open source software that is developed and
22+maintained by [Jane Street][js].
33+44+Contributions to this project are welcome and should be submitted via
55+GitHub pull requests.
66+77+Signing contributions
88+---------------------
99+1010+We require that you sign your contributions. Your signature certifies
1111+that you wrote the patch or otherwise have the right to pass it on as
1212+an open-source patch. The rules are pretty simple: if you can certify
1313+the below (from [developercertificate.org][dco]):
1414+1515+```
1616+Developer Certificate of Origin
1717+Version 1.1
1818+1919+Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
2020+1 Letterman Drive
2121+Suite D4700
2222+San Francisco, CA, 94129
2323+2424+Everyone is permitted to copy and distribute verbatim copies of this
2525+license document, but changing it is not allowed.
2626+2727+2828+Developer's Certificate of Origin 1.1
2929+3030+By making a contribution to this project, I certify that:
3131+3232+(a) The contribution was created in whole or in part by me and I
3333+ have the right to submit it under the open source license
3434+ indicated in the file; or
3535+3636+(b) The contribution is based upon previous work that, to the best
3737+ of my knowledge, is covered under an appropriate open source
3838+ license and I have the right under that license to submit that
3939+ work with modifications, whether created in whole or in part
4040+ by me, under the same open source license (unless I am
4141+ permitted to submit under a different license), as indicated
4242+ in the file; or
4343+4444+(c) The contribution was provided directly to me by some other
4545+ person who certified (a), (b) or (c) and I have not modified
4646+ it.
4747+4848+(d) I understand and agree that this project and the contribution
4949+ are public and that a record of the contribution (including all
5050+ personal information I submit with it, including my sign-off) is
5151+ maintained indefinitely and may be redistributed consistent with
5252+ this project or the open source license(s) involved.
5353+```
5454+5555+Then you just add a line to every git commit message:
5656+5757+```
5858+Signed-off-by: Joe Smith <joe.smith@email.com>
5959+```
6060+6161+Use your real name (sorry, no pseudonyms or anonymous contributions.)
6262+6363+If you set your `user.name` and `user.email` git configs, you can sign
6464+your commit automatically with git commit -s.
6565+6666+[dco]: http://developercertificate.org/
6767+[js]: https://opensource.janestreet.com/
+21
vendor/opam/ppxlib_jane/LICENSE.md
···11+The MIT License
22+33+Copyright (c) 2023--2025 Jane Street Group, LLC <opensource-contacts@janestreet.com>
44+55+Permission is hereby granted, free of charge, to any person obtaining a copy
66+of this software and associated documentation files (the "Software"), to deal
77+in the Software without restriction, including without limitation the rights
88+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99+copies of the Software, and to permit persons to whom the Software is
1010+furnished to do so, subject to the following conditions:
1111+1212+The above copyright notice and this permission notice shall be included in all
1313+copies or substantial portions of the Software.
1414+1515+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121+SOFTWARE.
···11+'`ppxlib_jane`'
22+===============
33+44+A library for use in ppxes for constructing and matching on ASTs corresponding to the
55+augmented parsetree that is recognized by the [Jane Street OCaml compiler][JaneStreetOCaml].
66+77+ASTs constructed using this library are compatible with the standard OCaml compiler. Any
88+syntax change known to this library is encoded as attributes, and the standard OCaml
99+compiler's interpretation of the ASTs constructed by these library (which amounts to
1010+ignoring the attributes) is reasonable. That is, we only expose "unsurprising" things in
1111+this library. For example, if you construct an *n*-ary function using this library, the
1212+standard OCaml compiler will interpret it as *n* nested unary functions in the normal way.
1313+1414+Likewise, ppxes that use this library to match on Jane Street ASTs can also be used with
1515+the standard OCaml compiler. (The Jane Street AST cases of the match will just never be
1616+triggered when using the standard OCaml compiler.)
1717+1818+This is how we intend this library to fit into the broader ppx ecosystem:
1919+2020+```
2121++-------------+ +--------------+ +------------------+
2222+| | | | | |
2323+| ppxes +------>| ppxlib +----->+ compiler libs, |
2424+| | | | | ppxlib_ast, etc. |
2525++------+------+ +--------------+ | |
2626+ | +---------+--------+
2727+ | +---------------+ ^
2828+ | | | |
2929+ +------------->+ ppxlib_jane +---------------+
3030+ | |
3131+ +---------------+
3232+```
3333+3434+That is, there is no dependency between `ppxlib` and `ppxlib_jane`, and ppx authors
3535+are free to use `ppxlib_jane` if they want to construct AST nodes recognized by the
3636+Jane Street OCaml compiler.
3737+3838+[JaneStreetOCaml]: https://github.com/ocaml-flambda/flambda-backend
···11+open Astlib
22+open Ppxlib_ast.Asttypes
33+open Ppxlib_ast.Parsetree
44+55+module type S = sig
66+ type 'a with_loc
77+ type arrow_argument := Shim.arrow_argument
88+ type arrow_result := Shim.arrow_result
99+ type block_access := Shim.block_access
1010+ type modalities := Shim.Modalities.t
1111+ type modes := Shim.Modes.t
1212+ type include_kind := Shim.Include_kind.t
1313+ type index_kind = Shim.index_kind
1414+ type jkind_annotation := Shim.jkind_annotation
1515+ type unboxed_access := Shim.unboxed_access
1616+1717+ module Pcstr_tuple_arg := Shim.Pcstr_tuple_arg
1818+1919+ (** {2 Modes} *)
2020+2121+ (** Construct a [Ptyp_arrow] *)
2222+ val ptyp_arrow : (arrow_argument -> arrow_result -> core_type) with_loc
2323+2424+ (** Construct a multi-argument arrow type with the provided arguments and result.
2525+2626+ @raise [Invalid_argument] if the input list is empty. *)
2727+ val tarrow : (arrow_argument list -> arrow_result -> core_type) with_loc
2828+2929+ (** As [tarrow], but will return the result if the input list is empty rather than
3030+ erroring; this means the result type cannot have a mode annotation. *)
3131+ val tarrow_maybe : (arrow_argument list -> core_type -> core_type) with_loc
3232+3333+ (** [Pexp_let] with [let mutable] support *)
3434+ val pexp_let
3535+ : (mutable_flag -> rec_flag -> value_binding list -> expression -> expression)
3636+ with_loc
3737+3838+ (** Construct a [Pexp_constraint] with modes *)
3939+ val pexp_constraint : (expression -> core_type option -> modes -> expression) with_loc
4040+4141+ (** Construct a [Ppat_constraint] with modes *)
4242+ val ppat_constraint : (pattern -> core_type option -> modes -> pattern) with_loc
4343+4444+ (** Contruct a [value_binding] with modes *)
4545+ val value_binding
4646+ : (pat:pattern -> expr:expression -> modes:modes -> value_binding) with_loc
4747+4848+ (** Construct a [Pcstr_tuple], a representation for the contents of a tupled variant
4949+ constructor, that attaches the provided modalities to each field. *)
5050+ val pcstr_tuple : ((modalities * core_type) list -> constructor_arguments) with_loc
5151+5252+ (** Construct a [Psig_include] with modalities *)
5353+ val psig_include
5454+ : (modalities:modalities -> include_description -> signature_item) with_loc
5555+5656+ (** Construct a [signature] *)
5757+ val signature : (?modalities:modalities -> signature_item list -> signature) with_loc
5858+5959+ val pmty_signature : (signature -> module_type) with_loc
6060+6161+ (** Splits a possibly-modality-annotated field of a tupled variant constructor into a
6262+ pair of its modality and the unannotated field. If the resulting mode is [None],
6363+ then the field is returned unchanged. *)
6464+ val get_tuple_field_modalities : Pcstr_tuple_arg.t -> modalities * core_type
6565+6666+ (** Splits a possibly-modality-annotated label declaration into a pair of its modality
6767+ and the unannotated label declaration. If the resulting modality is [None], then the
6868+ label declaration is returned unchanged. *)
6969+ val get_label_declaration_modalities
7070+ : label_declaration
7171+ -> modalities * label_declaration
7272+7373+ val label_declaration
7474+ : (name:string Location.loc
7575+ -> mutable_:mutable_flag
7676+ -> modalities:modalities
7777+ -> type_:core_type
7878+ -> label_declaration)
7979+ with_loc
8080+8181+ val get_value_description_modalities
8282+ : value_description
8383+ -> modalities * value_description
8484+8585+ val value_description
8686+ : (name:string Location.loc
8787+ -> type_:core_type
8888+ -> modalities:modalities
8989+ -> prim:string list
9090+ -> value_description)
9191+ with_loc
9292+9393+ val pcstr_tuple_arg
9494+ : (modalities:modalities -> type_:core_type -> Pcstr_tuple_arg.t) with_loc
9595+9696+ val include_infos
9797+ : (?attrs:attributes -> kind:include_kind -> 'a -> 'a include_infos) with_loc
9898+9999+ val module_declaration
100100+ : (?attrs:attributes
101101+ -> ?modalities:modalities
102102+ -> string option Location.loc
103103+ -> module_type
104104+ -> module_declaration)
105105+ with_loc
106106+107107+ val pmty_functor
108108+ : (?attrs:attributes
109109+ -> ?modes:modes
110110+ -> functor_parameter
111111+ -> module_type
112112+ -> module_type)
113113+ with_loc
114114+115115+ val pmod_constraint
116116+ : (?attrs:attributes -> module_expr -> module_type option -> modes -> module_expr)
117117+ with_loc
118118+119119+ (** {2 N-ary functions} *)
120120+121121+ (** Many comments below make reference to the Jane Street compiler's treatment of
122122+ function arity. These comments refer to a parsetree change made to upstream OCaml in
123123+ https://github.com/ocaml/ocaml/pull/12236, but that Jane Street has mirrored
124124+ internally already.
125125+126126+ The treatment of arity can be summarized as follows:
127127+ - In a previous version of OCaml, a function's runtime arity was inferred at a late
128128+ stage of the compiler, after typechecking, where it fuses together nested lambdas.
129129+ - In the new version of OCaml (both upstream OCaml after #12236 and the internal
130130+ Jane Street compiler), a function's runtime arity is purely a syntactic notion:
131131+ it's the number of parameters in a [fun x1 ... xn -> body] construct, with some
132132+ special allowances for function cases.
133133+134134+ Why is arity important? In native code, application sites of a function to [n]
135135+ syntactic arguments will trigger a fast path (where arguments are passed in
136136+ registers) only if the function's runtime arity is [n].
137137+138138+ As a result, ppxes must take more care than before to generate functions of the
139139+ correct arity. Now, a nested function like [fun x -> fun y -> e] has arity 1
140140+ (returning still another function of arity 1) instead of arity 2. All bindings below
141141+ that construct functions are documented as to the arity of the returned function.
142142+143143+ Some examples of arity:
144144+ - 2-ary function: [fun x y -> e]
145145+ - 1-ary function returning 1-ary function: [fun x -> fun y -> e]
146146+ - 3-ary function: [fun x y -> function P1 -> e1 | P2 -> e2]
147147+ - 2-ary function returning 1-ary function:
148148+ [fun x y -> (function P1 -> e1 | P2 -> e2)]
149149+ - 2-ary function returning 1-ary function:
150150+ [fun x -> function P1 -> function P2 -> e]
151151+152152+ Notably, unparenthesized [function] has a special meaning when used as a direct body
153153+ of [fun]: the [function] becomes part of the arity of the outer [fun]. The same does
154154+ not apply for multiple nested [function]s, even if they each have a single case; the
155155+ nested [function]s are treated as unary. (See the last example.) *)
156156+157157+ type function_param = Shim.Pexp_function.function_param
158158+ type function_constraint = Shim.Pexp_function.Function_constraint.t
159159+ type function_body = Shim.Pexp_function.function_body
160160+161161+ module Latest : sig
162162+ (** Avoid shadowing Ppxlib's AST builder. *)
163163+164164+ val ptyp_any : (jkind_annotation option -> core_type) with_loc
165165+ val ptyp_var : (string -> jkind_annotation option -> core_type) with_loc
166166+167167+ val pexp_function
168168+ : (?attrs:attributes
169169+ -> function_param list
170170+ -> function_constraint
171171+ -> function_body
172172+ -> expression)
173173+ with_loc
174174+ end
175175+176176+ (** Create a function with unlabeled parameters and an expression body. Like
177177+ {!Ppxlib.Ast_builder.eapply}, but for constructing functions.
178178+179179+ [coalesce_fun_arity] is relevant for the Jane Street compiler. By default,
180180+ [coalesce_fun_arity] is [true].
181181+182182+ Suppose there is a call [eabstract pats body ~coalesce_fun_arity]
183183+ - If [colaesce_fun_arity] is [true], the arity of the returned function is the same
184184+ as the arity of: [add_fun_params (List.map params ~f:(Fun.param Nolabel)) body]
185185+ - If [coalesce_fun_arity] is [false], then the arity of the returned function is the
186186+ length of [pats].
187187+188188+ In other words, [coalesce_fun_arity = true] allows you to build up the arity of an
189189+ already-constructed function rather than necessarily creating a new function. *)
190190+ val eabstract
191191+ : (?coalesce_fun_arity:bool
192192+ -> ?return_constraint:core_type
193193+ -> pattern list
194194+ -> expression
195195+ -> expression)
196196+ with_loc
197197+198198+ (** [unary_function cases] is [function <cases>]. When used with the Jane Street
199199+ compiler, the function's runtime arity is 1, so the fast path for function
200200+ application happens only when application sites of the resulting function receive 1
201201+ argument. To create a function with multiple argument that pattern-matches on the
202202+ last one, use [add_param] or [add_params] to add more parameters. Alternatively, use
203203+ [pexp_function] to provide all parameters at once.
204204+205205+ The attributes of the resulting expression will be the [attrs] argument together
206206+ with any attributes added by the Jane Street compiler. *)
207207+ val unary_function : (?attrs:attributes -> case list -> expression) with_loc
208208+209209+ (** [fun_param lbl pat] is [Pparam_val (lbl, None, pat)]. This gives a more
210210+ self-documenting way of constructing the usual case: value parameters without
211211+ optional argument defaults. *)
212212+ val fun_param : (arg_label -> pattern -> function_param) with_loc
213213+214214+ (** Say an expression is a "function" if it is a [Pexp_fun] or a [Pexp_function]. All
215215+ functions have parameters and arity.
216216+217217+ Suppose [add_param lbl def pat e ==> e']. Then, letting
218218+ [param = Pparam_val (lbl, def, pat)],
219219+ - If [e] is a function with arity [n], then [e'] is a function with arity [n+1].
220220+ [param] is added at the outermost layer. For example, if
221221+ [e = fun <params> -> <body>], then [e' = fun <param :: params> -> body]. The
222222+ attributes on the resulting expression will be the [attrs] argument together with
223223+ any attributes already present on [e].
224224+ - If [e] is not a function, then [e'] is a function with arity [1], namely:
225225+ [fun <param> -> <e>]. The attributes of the resulting expression will be the
226226+ [attrs] argument together with any attributes added by the Jane Street compiler. *)
227227+ val add_fun_param
228228+ : (?attrs:attributes
229229+ -> ?return_constraint:core_type
230230+ -> arg_label
231231+ -> expression option
232232+ -> pattern
233233+ -> expression
234234+ -> expression)
235235+ with_loc
236236+237237+ (** [add_params params e] is [List.fold_right params ~init:e ~f:add_param]. Note the
238238+ [fold_right]: if [e] is [fun <params'> -> <body>], then [add_params params e] is
239239+ [fun <params @ params'> -> <body>]. *)
240240+ val add_fun_params
241241+ : (?attrs:attributes
242242+ -> ?return_constraint:core_type
243243+ -> function_param list
244244+ -> expression
245245+ -> expression)
246246+ with_loc
247247+248248+ (** This operation is a no-op, except as interpreted by the Jane Street compiler. If [e]
249249+ is a function with arity [n] with an expression body that itself is a function with
250250+ arity [m], then [coalesce_fun_arity e] is a function of arity [n + m].
251251+252252+ You should usually call [coalesce_fun_arity] on metaquot fun expressions whose body
253253+ may be a function, e.g.:
254254+255255+ [coalesce_fun_arity [%expr fun x y -> [%e possibly_function]]] *)
256256+ val coalesce_fun_arity : expression -> expression
257257+258258+ (** {2 Unboxed types} *)
259259+260260+ val ptyp_unboxed_tuple : ((string option * core_type) list -> core_type) with_loc
261261+262262+ val pexp_unboxed_tuple
263263+ : (?attrs:attributes -> (string option * expression) list -> expression) with_loc
264264+265265+ val pexp_record_unboxed_product
266266+ : (?attrs:attributes
267267+ -> (Longident.t loc * expression) list
268268+ -> expression option
269269+ -> expression)
270270+ with_loc
271271+272272+ val ppat_record_unboxed_product
273273+ : (?attrs:attributes -> (Longident.t loc * pattern) list -> closed_flag -> pattern)
274274+ with_loc
275275+276276+ val pexp_unboxed_field
277277+ : (?attrs:attributes -> expression -> Longident.t loc -> expression) with_loc
278278+279279+ val ppat_unboxed_tuple
280280+ : (?attrs:attributes -> (string option * pattern) list -> closed_flag -> pattern)
281281+ with_loc
282282+283283+ val pexp_idx
284284+ : (?attrs:attributes -> block_access -> unboxed_access list -> expression) with_loc
285285+286286+ (** {3 Expression literals} *)
287287+288288+ (** e.g. [#42L] *)
289289+ val eint64_u : (int64 -> expression) with_loc
290290+291291+ (** e.g. [#42l] *)
292292+ val eint32_u : (int32 -> expression) with_loc
293293+294294+ (** e.g. [#42n] *)
295295+ val enativeint_u : (nativeint -> expression) with_loc
296296+297297+ (** e.g. [#42.] *)
298298+ val efloat_u : (string -> expression) with_loc
299299+300300+ (** {3 Pattern literals} *)
301301+302302+ (** e.g. [#42L] *)
303303+ val pint64_u : (int64 -> pattern) with_loc
304304+305305+ (** e.g. [#42l] *)
306306+ val pint32_u : (int32 -> pattern) with_loc
307307+308308+ (** e.g. [#42n] *)
309309+ val pnativeint_u : (nativeint -> pattern) with_loc
310310+311311+ (** e.g. [#42.] *)
312312+ val pfloat_u : (string -> pattern) with_loc
313313+314314+ (** {3 Layouts} *)
315315+316316+ val ptyp_alias
317317+ : (?attrs:attributes
318318+ -> core_type
319319+ -> label loc option
320320+ -> jkind_annotation option
321321+ -> core_type)
322322+ with_loc
323323+324324+ val ptyp_poly
325325+ : (?attrs:attributes
326326+ -> (string loc * jkind_annotation option) list
327327+ -> core_type
328328+ -> core_type)
329329+ with_loc
330330+331331+ val ptyp_quote : (?attrs:attributes -> core_type -> core_type) with_loc
332332+ val ptyp_splice : (?attrs:attributes -> core_type -> core_type) with_loc
333333+334334+ val pexp_newtype
335335+ : (?attrs:attributes
336336+ -> string loc
337337+ -> jkind_annotation option
338338+ -> expression
339339+ -> expression)
340340+ with_loc
341341+342342+ val type_declaration
343343+ : (?attrs:attributes
344344+ -> ?jkind_annotation:jkind_annotation
345345+ -> name:string Location.loc
346346+ -> params:(core_type * (variance * injectivity)) list
347347+ -> cstrs:(core_type * core_type * Location.t) list
348348+ -> kind:type_kind
349349+ -> private_:private_flag
350350+ -> manifest:core_type option
351351+ -> unit
352352+ -> type_declaration)
353353+ with_loc
354354+355355+ (** {2 Labeled tuples} *)
356356+357357+ val ptyp_tuple
358358+ : (?attrs:attributes -> (string option * core_type) list -> core_type) with_loc
359359+360360+ val pexp_tuple
361361+ : (?attrs:attributes -> (string option * expression) list -> expression) with_loc
362362+363363+ val ppat_tuple
364364+ : (?attrs:attributes -> (string option * pattern) list -> closed_flag -> pattern)
365365+ with_loc
366366+367367+ (** {2 Immutable arrays} *)
368368+369369+ val ppat_array : (?attrs:attributes -> mutable_flag -> pattern list -> pattern) with_loc
370370+371371+ val pexp_array
372372+ : (?attrs:attributes -> mutable_flag -> expression list -> expression) with_loc
373373+end
374374+375375+module type S_with_implicit_loc = S with type 'a with_loc := 'a
376376+module type S_with_explicit_loc = S with type 'a with_loc := loc:Location.t -> 'a
377377+378378+module type Ast_builder = sig
379379+ (** Jane Street-internal extensions to {!Ppxlib.Ast_builder}. The bindings below
380380+ ([Default], [Make], etc.) are parallel to bindings exported from
381381+ [Ppxlib.Ast_builder]. *)
382382+383383+ module type S_with_implicit_loc = S_with_implicit_loc
384384+385385+ module Default : S_with_explicit_loc
386386+387387+ module Make (Loc : sig
388388+ val loc : Location.t
389389+ end) : S_with_implicit_loc
390390+391391+ val make : Location.t -> (module S_with_implicit_loc)
392392+end
···11+open Ppxlib_ast.Asttypes
22+open Ppxlib_ast.Parsetree
33+44+let not_a_type_parameter ~loc =
55+ Astlib.Location.Error.make { loc; txt = "not a named type parameter" } ~sub:[]
66+;;
77+88+let get_type_param_name_and_jkind_res ty =
99+ let loc = ty.ptyp_loc in
1010+ match Shim.Core_type_desc.of_parsetree ty.ptyp_desc with
1111+ | Ptyp_var (name, jkind) -> Ok ({ loc; txt = name }, jkind)
1212+ | _ -> Error (not_a_type_parameter ~loc)
1313+;;
1414+1515+let get_type_param_name_and_jkind_of_core_type t =
1616+ match get_type_param_name_and_jkind_res t with
1717+ | Ok e -> e
1818+ | Error err -> Ppxlib_ast.Location_error.raise err
1919+;;
2020+2121+let get_type_param_name_and_jkind (t, _) = get_type_param_name_and_jkind_of_core_type t
2222+2323+let as_unlabeled_tuple components =
2424+ if List.for_all (fun (label, _) -> Option.is_none label) components
2525+ then Some (List.map snd components)
2626+ else None
2727+;;
2828+2929+let mangle_longident ~suffix : Longident.t -> Longident.t = function
3030+ | Lident name -> Lident (name ^ suffix)
3131+ | Ldot (path, name) -> Ldot (path, name ^ suffix)
3232+ | Lapply _ as longident -> longident
3333+;;
3434+3535+let localize_longident = mangle_longident ~suffix:"__local"
3636+let stackify_longident = mangle_longident ~suffix:"__stack"
3737+3838+let mangle_include_sig incl ~f =
3939+ { incl with
4040+ pincl_mod =
4141+ { incl.pincl_mod with
4242+ pmty_desc =
4343+ (match incl.pincl_mod.pmty_desc with
4444+ | Pmty_ident { txt; loc } -> Pmty_ident { txt = f txt; loc }
4545+ | Pmty_with (({ pmty_desc = Pmty_ident { txt; loc }; _ } as mty), cstrs) ->
4646+ Pmty_with ({ mty with pmty_desc = Pmty_ident { txt = f txt; loc } }, cstrs)
4747+ | _ -> failwith "expected [include S] or [include S with ...]")
4848+ }
4949+ }
5050+;;
5151+5252+let localize_include_sig incl = mangle_include_sig incl ~f:localize_longident
5353+let stackify_include_sig incl = mangle_include_sig incl ~f:stackify_longident
5454+5555+let append_arbitrary_suffix_to_include_signature incl ~suffix =
5656+ mangle_include_sig incl ~f:(mangle_longident ~suffix)
5757+;;
+37
vendor/opam/ppxlib_jane/src/common.mli
···11+open Ppxlib_ast
22+33+(** Similar to {!Ppxlib.get_type_param_name}, but also tells you the jkind of the
44+ variable. Raises a located error in case of failure. The type parameter should not be
55+ [_]. One way to ensure this is to get the type from {!Ppxlib.name_type_params_in_td}
66+ (or one of the similarly-named functions). *)
77+val get_type_param_name_and_jkind
88+ : Parsetree.core_type * (Asttypes.variance * Asttypes.injectivity)
99+ -> string Location.loc * Shim.jkind_annotation option
1010+1111+val get_type_param_name_and_jkind_of_core_type
1212+ : Parsetree.core_type
1313+ -> string Location.loc * Shim.jkind_annotation option
1414+1515+(** Check if the parsetree is of an unlabeled tuple (i.e. all labels are [None]), and
1616+ return the components of the tuple dropping its [None] labels. *)
1717+val as_unlabeled_tuple : (string option * 'a) list -> 'a list option
1818+1919+(** Modifies an [include_description] to append "__local" to the module type name. In
2020+ particular, this is useful for modifying the result of {!Ppxlib.mk_named_sig}. For
2121+ example, if the latter produces some [incl] representing
2222+ [include Bin_prot.Binable.S1 with type 'a t := 'a t], calling
2323+ [localize_include_sig incl] will turn this into
2424+ [include Bin_prot.Binable.S1__local with type 'a t := 'a t]. *)
2525+val localize_include_sig : Ast.include_description -> Ast.include_description
2626+2727+(** Like [localize_include_sig], but appends "__stack" rather than "__local". *)
2828+val stackify_include_sig : Ast.include_description -> Ast.include_description
2929+3030+(** Like [localize_include_sig], but appends an arbitrary suffix.
3131+3232+ This is useful when the suffix for your signature is not a standard mangling suffix as
3333+ produced by [ppx_template]. *)
3434+val append_arbitrary_suffix_to_include_signature
3535+ : Ast.include_description
3636+ -> suffix:string
3737+ -> Ast.include_description
···11+open! Astlib
22+open! Ppxlib_ast.Asttypes
33+open! Ppxlib_ast.Parsetree
44+55+type legacy_pexp_fun = arg_label * expression option * pattern * expression
66+type legacy_pexp_function = case list
77+type legacy_pexp_newtype = string loc * expression
88+99+type t =
1010+ | Legacy_pexp_fun of legacy_pexp_fun
1111+ (** Match [Pexp_fun], as in the OCaml parsetree prior to 5.2. To construct, use
1212+ [Ppxlib.Ast_builder.Default.pexp_fun]. *)
1313+ | Legacy_pexp_function of legacy_pexp_function
1414+ (** Match [Pexp_function], as in the OCaml parsetree prior to 5.2. To construct, use
1515+ [Ppxlib.Ast_builder.Default.pexp_function]. *)
1616+ | Legacy_pexp_newtype of legacy_pexp_newtype
1717+1818+let of_pexp_function
1919+ ~(params : Shim.Pexp_function.function_param list)
2020+ ~(constraint_ : Shim.Pexp_function.Function_constraint.t)
2121+ ~(body : Shim.Pexp_function.function_body)
2222+ =
2323+ match params, body with
2424+ | [], Pfunction_cases (cases, _, _) -> Legacy_pexp_function cases
2525+ | { pparam_desc = first_param; pparam_loc } :: params, _ ->
2626+ let body =
2727+ match params, body with
2828+ (* The remaining body is still a valid function: we either
2929+ have more parameters in the list, or the body is function
3030+ cases (which implies a parameter).
3131+ *)
3232+ | _ :: _, _ | [], Pfunction_cases _ ->
3333+ let body_loc =
3434+ match body with
3535+ | Pfunction_body body -> body.pexp_loc
3636+ | Pfunction_cases (_, body_loc, _) -> body_loc
3737+ in
3838+ let rest_loc : Location.t =
3939+ { loc_start = pparam_loc.loc_end; loc_end = body_loc.loc_end; loc_ghost = true }
4040+ in
4141+ let rest_fun = Shim.Pexp_function.to_parsetree ~params ~constraint_ ~body in
4242+ Ppxlib_ast.Ast_helper.Exp.mk rest_fun ~loc:rest_loc
4343+ (* The remaining body is not a valid function, and we just return it directly. *)
4444+ | [], Pfunction_body expr ->
4545+ (match constraint_ with
4646+ | c when Shim.Pexp_function.Function_constraint.is_none c -> expr
4747+ | ({ ret_type_constraint; ret_mode_annotations; mode_annotations = _ } :
4848+ Shim.Pexp_function.Function_constraint.t) ->
4949+ let loc = { expr.pexp_loc with loc_ghost = true } in
5050+ let pexp_desc =
5151+ match ret_type_constraint with
5252+ | Some (Pcoerce (ty1, ty2)) -> Pexp_coerce (expr, ty1, ty2)
5353+ | Some (Pconstraint ty) ->
5454+ Pexp_constraint (expr, Some ty, ret_mode_annotations)
5555+ |> Shim.Expression_desc.to_parsetree ~loc
5656+ | None ->
5757+ Pexp_constraint (expr, None, ret_mode_annotations)
5858+ |> Shim.Expression_desc.to_parsetree ~loc
5959+ in
6060+ Ppxlib_ast.Ast_helper.Exp.mk pexp_desc ~loc)
6161+ in
6262+ (match first_param with
6363+ | Pparam_val (lbl, opt, pat) -> Legacy_pexp_fun (lbl, opt, pat, body)
6464+ | Pparam_newtype (newtype, _jkind) -> Legacy_pexp_newtype (newtype, body))
6565+ | _, Pfunction_body body ->
6666+ Location.raise_errorf "empty function body" ~loc:body.pexp_loc
6767+;;
6868+6969+let of_parsetree expression =
7070+ Option.map
7171+ (fun (params, constraint_, body) -> of_pexp_function ~params ~constraint_ ~body)
7272+ (Shim.Pexp_function.of_parsetree
7373+ expression
7474+ (* This location is just filled in as the [Pfunction_cases] location,
7575+ and [of_pexp_function] drops that location.
7676+ *)
7777+ ~loc:Location.none)
7878+;;
7979+8080+let legacy_pexp_fun_of_parsetree expression =
8181+ match of_parsetree expression with
8282+ | Some (Legacy_pexp_fun x) -> Some x
8383+ | _ -> None
8484+;;
8585+8686+let legacy_pexp_function_of_parsetree expression =
8787+ match of_parsetree expression with
8888+ | Some (Legacy_pexp_function x) -> Some x
8989+ | _ -> None
9090+;;
9191+9292+let legacy_pexp_newtype_of_parsetree expression =
9393+ match of_parsetree expression with
9494+ | Some (Legacy_pexp_newtype x) -> Some x
9595+ | _ -> None
9696+;;
···11+open! Astlib
22+open! Ppxlib_ast.Asttypes
33+open! Ppxlib_ast.Parsetree
44+55+(** Use of this module is discouraged.
66+77+ This module allows you to turn matches on [Pexp_function (params, constraint_, body)]
88+ into matches on the old parsetree prior to OCaml 5.2:
99+ - [Pexp_newtype (newtype, body)]
1010+ - [Pexp_fun (label, default, pat)]
1111+ - [Pexp_function cases]
1212+1313+ These constructors are available below, but with [Legacy_] tacked onto the name.
1414+1515+ Generally, ppx authors should prefer handling the new [Pexp_function] constructor
1616+ directly. This module was introduced to make it easier to update old ppxes, but it has
1717+ less obvious behavior and is kludgy. *)
1818+1919+type legacy_pexp_fun := arg_label * expression option * pattern * expression
2020+type legacy_pexp_function := case list
2121+type legacy_pexp_newtype := string loc * expression
2222+2323+type t =
2424+ | Legacy_pexp_fun of legacy_pexp_fun
2525+ (** Match [Pexp_fun], as in the OCaml parsetree prior to 5.2. To construct, use
2626+ [Ppxlib.Ast_builder.Default.pexp_fun]. *)
2727+ | Legacy_pexp_function of legacy_pexp_function
2828+ (** Match [Pexp_function], as in the OCaml parsetree prior to 5.2. To construct, use
2929+ [Ppxlib.Ast_builder.Default.pexp_function]. *)
3030+ | Legacy_pexp_newtype of legacy_pexp_newtype
3131+3232+(** Creation functions *)
3333+3434+val of_parsetree : expression_desc -> t option
3535+3636+val of_pexp_function
3737+ : params:Shim.Pexp_function.function_param list
3838+ -> constraint_:Shim.Pexp_function.Function_constraint.t
3939+ -> body:Shim.Pexp_function.function_body
4040+ -> t
4141+4242+(** Testing a particular constructor of [t]. *)
4343+4444+val legacy_pexp_fun_of_parsetree : expression_desc -> legacy_pexp_fun option
4545+val legacy_pexp_function_of_parsetree : expression_desc -> legacy_pexp_function option
4646+val legacy_pexp_newtype_of_parsetree : expression_desc -> legacy_pexp_newtype option
···11+open! Stdppx
22+33+(** A human-readable name for the language feature corresponding to the construct. *)
44+module Language_feature_name : sig
55+ val of_core_type_desc : Shim.Core_type_desc.t -> string
66+ val of_expression_desc : Shim.Expression_desc.t -> string
77+ val of_pattern_desc : Shim.Pattern_desc.t -> string
88+ val of_signature_item_desc : Shim.Signature_item_desc.t -> string
99+ val of_structure_item_desc : Shim.Structure_item_desc.t -> string
1010+ val of_module_type_desc : Shim.Module_type_desc.t -> string
1111+ val of_module_expr_desc : Shim.Module_expr_desc.t -> string
1212+end
1313+1414+(** The literal name of the constructor corresponding to the construct (e.g. Pexp_ident) *)
1515+module Constructor_name : sig
1616+ val of_core_type_desc : Shim.Core_type_desc.t -> string
1717+ val of_expression_desc : Shim.Expression_desc.t -> string
1818+ val of_pattern_desc : Shim.Pattern_desc.t -> string
1919+ val of_signature_item_desc : Shim.Signature_item_desc.t -> string
2020+ val of_structure_item_desc : Shim.Structure_item_desc.t -> string
2121+ val of_module_type_desc : Shim.Module_type_desc.t -> string
2222+ val of_module_expr_desc : Shim.Module_expr_desc.t -> string
2323+end
···11+open Astlib
22+open Ppxlib_ast.Asttypes
33+open Ppxlib_ast.Parsetree
44+module Ast_helper = Ppxlib_ast.Ast_helper
55+66+module Modality = struct
77+ type nonrec t = Modality of string [@@unboxed]
88+end
99+1010+module Modalities = struct
1111+ type t = Modality.t loc list
1212+1313+ let none = []
1414+ let portable ~loc = [ { txt = Modality.Modality "portable"; loc } ]
1515+end
1616+1717+module Mode = struct
1818+ type t = Mode of string [@@unboxed]
1919+end
2020+2121+module Modes = struct
2222+ type t = Mode.t loc list
2323+2424+ let none = []
2525+ let local ~loc = [ { txt = Mode.Mode "local"; loc } ]
2626+end
2727+2828+module Include_kind = struct
2929+ type t =
3030+ | Structure
3131+ | Functor
3232+end
3333+3434+type arrow_argument =
3535+ { arg_label : arg_label
3636+ ; arg_modes : Modes.t
3737+ ; arg_type : core_type
3838+ }
3939+4040+type arrow_result =
4141+ { result_modes : Modes.t
4242+ ; result_type : core_type
4343+ }
4444+4545+module Pcstr_tuple_arg = struct
4646+ type t = core_type
4747+4848+ let extract_modalities t = [], t
4949+ let to_core_type t = t
5050+ let of_core_type core_type = core_type
5151+ let map_core_type t ~f = f t
5252+ let map_core_type_extra t ~f = f t
5353+ let create ~loc:_ ~modalities:_ ~type_ = type_
5454+end
5555+5656+module Label_declaration = struct
5757+ let extract_modalities ld = [], ld
5858+5959+ let create ~loc ~name ~mutable_ ~modalities:_ ~type_ =
6060+ { pld_loc = loc
6161+ ; pld_name = name
6262+ ; pld_type = type_
6363+ ; pld_mutable = mutable_
6464+ ; pld_attributes = []
6565+ }
6666+ ;;
6767+end
6868+6969+module Value_description = struct
7070+ let extract_modalities vd = [], vd
7171+7272+ let create ~loc ~name ~type_ ~modalities:_ ~prim =
7373+ { pval_loc = loc
7474+ ; pval_name = name
7575+ ; pval_type = type_
7676+ ; pval_prim = prim
7777+ ; pval_attributes = []
7878+ }
7979+ ;;
8080+end
8181+8282+module Module_declaration = struct
8383+ type t =
8484+ { pmd_name : string option loc
8585+ ; pmd_type : module_type
8686+ ; pmd_modalities : Modalities.t
8787+ ; pmd_attributes : attributes (** [... [\@\@id1] [\@\@id2]] *)
8888+ ; pmd_loc : Location.t
8989+ }
9090+9191+ let to_parsetree
9292+ ({ pmd_name; pmd_type; pmd_attributes; pmd_loc; pmd_modalities = _ } : t)
9393+ : module_declaration
9494+ =
9595+ { pmd_name; pmd_type; pmd_attributes; pmd_loc }
9696+ ;;
9797+9898+ let of_parsetree ({ pmd_name; pmd_type; pmd_attributes; pmd_loc } : module_declaration)
9999+ : t
100100+ =
101101+ let pmd_modalities = [] in
102102+ { pmd_name; pmd_type; pmd_attributes; pmd_loc; pmd_modalities }
103103+ ;;
104104+end
105105+106106+module Value_binding = struct
107107+ let extract_modes vb = [], vb
108108+109109+ let create ~loc ~pat ~expr ~modes:_ =
110110+ { pvb_pat = pat; pvb_expr = expr; pvb_attributes = []; pvb_loc = loc }
111111+ ;;
112112+end
113113+114114+module T = struct
115115+ type jkind_annotation_desc =
116116+ | Pjk_default
117117+ | Pjk_abbreviation of string
118118+ | Pjk_mod of jkind_annotation * Modes.t
119119+ | Pjk_with of jkind_annotation * core_type * Modalities.t
120120+ | Pjk_kind_of of core_type
121121+ | Pjk_product of jkind_annotation list
122122+123123+ and jkind_annotation =
124124+ { pjkind_loc : Location.t
125125+ ; pjkind_desc : jkind_annotation_desc
126126+ }
127127+end
128128+129129+include T
130130+131131+module Type_declaration = struct
132132+ type t =
133133+ { ptype_name : string loc
134134+ ; ptype_params : (core_type * (variance * injectivity)) list
135135+ ; ptype_cstrs : (core_type * core_type * Location.t) list
136136+ ; ptype_kind : type_kind
137137+ ; ptype_private : private_flag
138138+ ; ptype_manifest : core_type option
139139+ ; ptype_attributes : attributes
140140+ ; ptype_jkind_annotation : jkind_annotation option
141141+ ; ptype_loc : Location.t
142142+ }
143143+144144+ let to_parsetree : t -> type_declaration =
145145+ fun { ptype_name
146146+ ; ptype_params
147147+ ; ptype_cstrs
148148+ ; ptype_kind
149149+ ; ptype_private
150150+ ; ptype_manifest
151151+ ; ptype_attributes
152152+ ; ptype_jkind_annotation = _
153153+ ; ptype_loc
154154+ } ->
155155+ { ptype_name
156156+ ; ptype_params
157157+ ; ptype_cstrs
158158+ ; ptype_kind
159159+ ; ptype_private
160160+ ; ptype_manifest
161161+ ; ptype_attributes
162162+ ; ptype_loc
163163+ }
164164+ ;;
165165+166166+ let of_parsetree : type_declaration -> t =
167167+ fun { ptype_name
168168+ ; ptype_params
169169+ ; ptype_cstrs
170170+ ; ptype_kind
171171+ ; ptype_private
172172+ ; ptype_manifest
173173+ ; ptype_attributes
174174+ ; ptype_loc
175175+ } ->
176176+ { ptype_name
177177+ ; ptype_params
178178+ ; ptype_cstrs
179179+ ; ptype_kind
180180+ ; ptype_private
181181+ ; ptype_manifest
182182+ ; ptype_attributes
183183+ ; ptype_jkind_annotation = None
184184+ ; ptype_loc
185185+ }
186186+ ;;
187187+188188+ let extract_jkind_annotation _ = None
189189+end
190190+191191+module Constant = struct
192192+ type t =
193193+ | Pconst_integer of string * char option
194194+ | Pconst_unboxed_integer of string * char
195195+ | Pconst_char of char
196196+ | Pconst_untagged_char of char
197197+ | Pconst_string of string * Location.t * string option
198198+ | Pconst_float of string * char option
199199+ | Pconst_unboxed_float of string * char option
200200+201201+ let of_parsetree : constant -> t = function
202202+ | Pconst_integer (a, b) -> Pconst_integer (a, b)
203203+ | Pconst_char a -> Pconst_char a
204204+ | Pconst_string (a, b, c) -> Pconst_string (a, b, c)
205205+ | Pconst_float (a, b) -> Pconst_float (a, b)
206206+ ;;
207207+208208+ let to_parsetree : t -> constant = function
209209+ | Pconst_integer (a, b) -> Pconst_integer (a, b)
210210+ | Pconst_char a -> Pconst_char a
211211+ | Pconst_string (a, b, c) -> Pconst_string (a, b, c)
212212+ | Pconst_float (a, b) -> Pconst_float (a, b)
213213+ (* Unboxed literal constants erase to boxed literals. *)
214214+ | Pconst_unboxed_integer (a, b) -> Pconst_integer (a, Some b)
215215+ | Pconst_unboxed_float (a, b) -> Pconst_float (a, b)
216216+ | Pconst_untagged_char a -> Pconst_char a
217217+ ;;
218218+end
219219+220220+module Pexp_function = struct
221221+ type function_param_desc =
222222+ | Pparam_val of arg_label * expression option * pattern
223223+ | Pparam_newtype of string loc * jkind_annotation option
224224+225225+ type function_param =
226226+ { pparam_loc : Location.t
227227+ ; pparam_desc : function_param_desc
228228+ }
229229+230230+ type type_constraint =
231231+ | Pconstraint of core_type
232232+ | Pcoerce of core_type option * core_type
233233+234234+ module Function_constraint = struct
235235+ type t =
236236+ { mode_annotations : Modes.t
237237+ ; ret_mode_annotations : Modes.t
238238+ ; ret_type_constraint : type_constraint option
239239+ }
240240+241241+ let none =
242242+ { mode_annotations = []; ret_mode_annotations = []; ret_type_constraint = None }
243243+ ;;
244244+245245+ let is_none { ret_mode_annotations; ret_type_constraint; _ } =
246246+ match ret_mode_annotations, ret_type_constraint with
247247+ | [], None -> true
248248+ | _, _ -> false
249249+ ;;
250250+ end
251251+252252+ type function_body =
253253+ | Pfunction_body of expression
254254+ | Pfunction_cases of case list * Location.t * attributes
255255+256256+ let to_parsetree
257257+ ~params
258258+ ~constraint_:
259259+ ({ mode_annotations = _; ret_mode_annotations = _; ret_type_constraint } :
260260+ Function_constraint.t)
261261+ ~body
262262+ =
263263+ let body =
264264+ match body with
265265+ | Pfunction_body body -> body
266266+ | Pfunction_cases (cases, loc, pexp_attributes) ->
267267+ Ast_helper.Exp.function_ cases ~loc ~attrs:pexp_attributes
268268+ in
269269+ let body =
270270+ match ret_type_constraint with
271271+ | None -> body
272272+ | Some (Pconstraint ty) ->
273273+ let body_loc = { body.pexp_loc with loc_ghost = true } in
274274+ Ast_helper.Exp.constraint_ body ty ~loc:body_loc
275275+ | Some (Pcoerce (ty1, ty2)) ->
276276+ let body_loc = { body.pexp_loc with loc_ghost = true } in
277277+ Ast_helper.Exp.coerce body ty1 ty2 ~loc:body_loc
278278+ in
279279+ let fun_ =
280280+ ListLabels.fold_right params ~init:body ~f:(fun param body ->
281281+ let loc : Location.t =
282282+ { loc_start = param.pparam_loc.loc_start
283283+ ; loc_end = body.pexp_loc.loc_end
284284+ ; loc_ghost = true
285285+ }
286286+ in
287287+ match param.pparam_desc with
288288+ | Pparam_val (lbl, eo, pat) -> Ast_helper.Exp.fun_ lbl eo pat body ~loc
289289+ | Pparam_newtype (newtype, _) -> Ast_helper.Exp.newtype newtype body ~loc)
290290+ in
291291+ fun_.pexp_desc
292292+ ;;
293293+294294+ let of_parsetree =
295295+ let body_of_parsetree body =
296296+ match body.pexp_desc with
297297+ | Pexp_function cases -> Pfunction_cases (cases, body.pexp_loc, body.pexp_attributes)
298298+ | _ -> Pfunction_body body
299299+ in
300300+ let finish ~rev_params ~constraint_ ~body =
301301+ let body = body_of_parsetree body in
302302+ match rev_params, constraint_, body with
303303+ | [], _, Pfunction_body _ -> None
304304+ | [], Some _, Pfunction_cases _ -> None
305305+ | rev_params, constraint_, body ->
306306+ let constraint_ : Function_constraint.t =
307307+ { Function_constraint.none with ret_type_constraint = constraint_ }
308308+ in
309309+ Some (List.rev rev_params, constraint_, body)
310310+ in
311311+ let rec loop_expr_desc expr_desc ~rev_params ~containing_expr =
312312+ match expr_desc with
313313+ | Pexp_newtype (ty, body) ->
314314+ loop_expr
315315+ body
316316+ ~rev_params:
317317+ ({ pparam_loc = ty.loc; pparam_desc = Pparam_newtype (ty, None) }
318318+ :: rev_params)
319319+ | Pexp_fun (lbl, eo, pat, body) ->
320320+ loop_expr
321321+ body
322322+ ~rev_params:
323323+ ({ pparam_loc = pat.ppat_loc; pparam_desc = Pparam_val (lbl, eo, pat) }
324324+ :: rev_params)
325325+ | Pexp_constraint (body, ty) ->
326326+ finish ~rev_params ~constraint_:(Some (Pconstraint ty)) ~body
327327+ | _ ->
328328+ (match containing_expr with
329329+ | None -> None
330330+ | Some body -> finish ~rev_params ~constraint_:None ~body)
331331+ and loop_expr expr ~rev_params =
332332+ match expr.pexp_attributes with
333333+ | _ :: _ -> finish ~rev_params ~constraint_:None ~body:expr
334334+ | [] -> loop_expr_desc expr.pexp_desc ~rev_params ~containing_expr:(Some expr)
335335+ in
336336+ fun expr_desc ~loc ->
337337+ match expr_desc with
338338+ | Pexp_function cases ->
339339+ Some ([], Function_constraint.none, Pfunction_cases (cases, loc, []))
340340+ | _ -> loop_expr_desc expr_desc ~rev_params:[] ~containing_expr:None
341341+ ;;
342342+end
343343+344344+let ptyp_any =
345345+ { ptyp_desc = Ptyp_any
346346+ ; ptyp_loc = Location.none
347347+ ; ptyp_loc_stack = []
348348+ ; ptyp_attributes = []
349349+ }
350350+;;
351351+352352+let add_none_labels l = List.map (fun x -> None, x) l
353353+354354+(* Duplicated from [common.ml] to avoid dependency cycle *)
355355+let as_unlabeled_tuple components =
356356+ if List.for_all (fun (label, _) -> Option.is_none label) components
357357+ then Some (List.map snd components)
358358+ else None
359359+;;
360360+361361+let as_unlabeled_tuple_unconditionally components = List.map snd components
362362+363363+type index_kind =
364364+ | Index_int
365365+ | Index_unboxed_int64
366366+ | Index_unboxed_int32
367367+ | Index_unboxed_int16
368368+ | Index_unboxed_int8
369369+ | Index_unboxed_nativeint
370370+371371+type block_access =
372372+ | Baccess_field of Longident.t loc
373373+ | Baccess_array of mutable_flag * index_kind * expression
374374+ | Baccess_block of mutable_flag * expression
375375+376376+type unboxed_access = Uaccess_unboxed_field of Longident.t loc
377377+378378+module Core_type_desc = struct
379379+ type t =
380380+ | Ptyp_any of jkind_annotation option
381381+ | Ptyp_var of string * jkind_annotation option
382382+ | Ptyp_arrow of arg_label * core_type * core_type * Modes.t * Modes.t
383383+ | Ptyp_tuple of (string option * core_type) list
384384+ | Ptyp_unboxed_tuple of (string option * core_type) list
385385+ | Ptyp_constr of Longident.t loc * core_type list
386386+ | Ptyp_object of object_field list * closed_flag
387387+ | Ptyp_class of Longident.t loc * core_type list
388388+ | Ptyp_alias of core_type * string loc option * jkind_annotation option
389389+ | Ptyp_variant of row_field list * closed_flag * label list option
390390+ | Ptyp_poly of (string loc * jkind_annotation option) list * core_type
391391+ | Ptyp_package of package_type
392392+ | Ptyp_quote of core_type
393393+ | Ptyp_splice of core_type
394394+ | Ptyp_of_kind of jkind_annotation
395395+ | Ptyp_extension of extension
396396+397397+ let of_parsetree : core_type_desc -> t = function
398398+ (* changed constructors *)
399399+ | Ptyp_arrow (a, b, c) -> Ptyp_arrow (a, b, c, [], [])
400400+ | Ptyp_tuple a -> Ptyp_tuple (add_none_labels a)
401401+ | Ptyp_any -> Ptyp_any None
402402+ | Ptyp_var s -> Ptyp_var (s, None)
403403+ | Ptyp_alias (a, b) ->
404404+ let ghost_alias_loc = { a.ptyp_loc with loc_ghost = true } in
405405+ Ptyp_alias (a, Some { txt = b; loc = ghost_alias_loc }, None)
406406+ | Ptyp_poly (a, b) -> Ptyp_poly (List.map (fun x -> x, None) a, b)
407407+ (* unchanged constructors *)
408408+ | Ptyp_constr (a, b) -> Ptyp_constr (a, b)
409409+ | Ptyp_object (a, b) -> Ptyp_object (a, b)
410410+ | Ptyp_class (a, b) -> Ptyp_class (a, b)
411411+ | Ptyp_variant (a, b, c) -> Ptyp_variant (a, b, c)
412412+ | Ptyp_package a -> Ptyp_package a
413413+ | Ptyp_extension a -> Ptyp_extension a
414414+ ;;
415415+416416+ let fresh_name =
417417+ let r = ref 0 in
418418+ fun name ->
419419+ let i = !r in
420420+ incr r;
421421+ name ^ string_of_int i
422422+ ;;
423423+424424+ let to_parsetree : t -> core_type_desc = function
425425+ (* changed constructors *)
426426+ | Ptyp_arrow (a, b, c, _, _) -> Ptyp_arrow (a, b, c)
427427+ | Ptyp_any (_ : jkind_annotation option) -> Ptyp_any
428428+ | Ptyp_var (s, _) -> Ptyp_var s
429429+ | Ptyp_poly (a, b) -> Ptyp_poly (List.map fst a, b)
430430+ | Ptyp_alias (a, Some b, _) -> Ptyp_alias (a, b.txt)
431431+ | Ptyp_alias (a, None, _) -> Ptyp_alias (a, fresh_name "_alias")
432432+ | Ptyp_tuple labeled_typs ->
433433+ Ptyp_tuple (as_unlabeled_tuple_unconditionally labeled_typs)
434434+ (* new constructors *)
435435+ | Ptyp_unboxed_tuple labeled_typs ->
436436+ Ptyp_tuple (as_unlabeled_tuple_unconditionally labeled_typs)
437437+ | Ptyp_of_kind _ -> failwith "[Ptyp_of_kind] unimplemented in ppxlib_jane"
438438+ (* unchanged constructors *)
439439+ | Ptyp_constr (a, b) -> Ptyp_constr (a, b)
440440+ | Ptyp_object (a, b) -> Ptyp_object (a, b)
441441+ | Ptyp_class (a, b) -> Ptyp_class (a, b)
442442+ | Ptyp_variant (a, b, c) -> Ptyp_variant (a, b, c)
443443+ | Ptyp_quote _ -> failwith "[Ptyp_quote] unimplemented in ppxlib_jane"
444444+ | Ptyp_splice _ -> failwith "[Ptyp_splice] unimplemented in ppxlib_jane"
445445+ | Ptyp_package a -> Ptyp_package a
446446+ | Ptyp_extension a -> Ptyp_extension a
447447+ ;;
448448+end
449449+450450+module Core_type = struct
451451+ type t =
452452+ { ptyp_desc : Core_type_desc.t
453453+ ; ptyp_loc : Location.t
454454+ ; ptyp_loc_stack : Location.t list
455455+ ; ptyp_attributes : attributes
456456+ }
457457+458458+ let of_parsetree
459459+ { Ppxlib_ast.Parsetree.ptyp_desc; ptyp_loc; ptyp_loc_stack; ptyp_attributes }
460460+ =
461461+ let ptyp_desc = Core_type_desc.of_parsetree ptyp_desc in
462462+ { ptyp_desc; ptyp_loc; ptyp_loc_stack; ptyp_attributes }
463463+ ;;
464464+465465+ let to_parsetree { ptyp_desc; ptyp_loc; ptyp_loc_stack; ptyp_attributes } =
466466+ let ptyp_desc = Core_type_desc.to_parsetree ptyp_desc in
467467+ { Ppxlib_ast.Parsetree.ptyp_desc; ptyp_loc; ptyp_loc_stack; ptyp_attributes }
468468+ ;;
469469+end
470470+471471+module Pattern_desc = struct
472472+ type t =
473473+ | Ppat_any
474474+ | Ppat_var of string loc
475475+ | Ppat_alias of pattern * string loc
476476+ | Ppat_constant of constant
477477+ | Ppat_interval of constant * constant
478478+ | Ppat_tuple of (string option * pattern) list * closed_flag
479479+ | Ppat_unboxed_tuple of (string option * pattern) list * closed_flag
480480+ | Ppat_construct of
481481+ Longident.t loc * ((string loc * jkind_annotation option) list * pattern) option
482482+ | Ppat_variant of label * pattern option
483483+ | Ppat_record of (Longident.t loc * pattern) list * closed_flag
484484+ | Ppat_record_unboxed_product of (Longident.t loc * pattern) list * closed_flag
485485+ | Ppat_array of mutable_flag * pattern list
486486+ | Ppat_or of pattern * pattern
487487+ | Ppat_constraint of pattern * core_type option * Modes.t
488488+ | Ppat_type of Longident.t loc
489489+ | Ppat_lazy of pattern
490490+ | Ppat_unpack of string option loc
491491+ | Ppat_exception of pattern
492492+ | Ppat_extension of extension
493493+ | Ppat_open of Longident.t loc * pattern
494494+495495+ let of_parsetree : pattern_desc -> t = function
496496+ (* changed constructors *)
497497+ | Ppat_constraint (a, b) -> Ppat_constraint (a, Some b, [])
498498+ | Ppat_tuple a -> Ppat_tuple (add_none_labels a, Closed)
499499+ | Ppat_construct (a, b) ->
500500+ let b =
501501+ Option.map (fun (vars, pattern) -> List.map (fun s -> s, None) vars, pattern) b
502502+ in
503503+ Ppat_construct (a, b)
504504+ (* unchanged constructors *)
505505+ | Ppat_any -> Ppat_any
506506+ | Ppat_var a -> Ppat_var a
507507+ | Ppat_alias (a, b) -> Ppat_alias (a, b)
508508+ | Ppat_constant a -> Ppat_constant a
509509+ | Ppat_interval (a, b) -> Ppat_interval (a, b)
510510+ | Ppat_variant (a, b) -> Ppat_variant (a, b)
511511+ | Ppat_record (a, b) -> Ppat_record (a, b)
512512+ | Ppat_array a -> Ppat_array (Mutable, a)
513513+ | Ppat_or (a, b) -> Ppat_or (a, b)
514514+ | Ppat_type a -> Ppat_type a
515515+ | Ppat_lazy a -> Ppat_lazy a
516516+ | Ppat_unpack a -> Ppat_unpack a
517517+ | Ppat_exception a -> Ppat_exception a
518518+ | Ppat_extension a -> Ppat_extension a
519519+ | Ppat_open (a, b) -> Ppat_open (a, b)
520520+ ;;
521521+522522+ let to_parsetree : loc:Location.t -> t -> pattern_desc =
523523+ fun ~loc -> function
524524+ (* changed constructors *)
525525+ | Ppat_constraint (a, Some b, _) -> Ppat_constraint (a, b)
526526+ | Ppat_constraint (a, None, _) -> Ppat_constraint (a, ptyp_any)
527527+ | Ppat_tuple (_, Open) ->
528528+ Location.raise_errorf
529529+ ~loc
530530+ "[Ppat_tuple] with an \"open\" pattern cannot be converted to an upstream \
531531+ [pattern_desc]"
532532+ | Ppat_tuple (labeled_pats, Closed) ->
533533+ (match as_unlabeled_tuple labeled_pats with
534534+ | Some pats -> Ppat_tuple pats
535535+ | None ->
536536+ failwith
537537+ "[Ppat_tuple], when labels are present, cannot be converted to an upstream \
538538+ [pattern_desc]")
539539+ | Ppat_array (Mutable, a) -> Ppat_array a
540540+ | Ppat_array (Immutable, _) ->
541541+ Location.raise_errorf
542542+ ~loc
543543+ "Immutable [Ppat_array] cannot be converted to an usptream [pattern_desc]"
544544+ (* new constructors *)
545545+ | Ppat_unboxed_tuple (_, Open) ->
546546+ Location.raise_errorf
547547+ ~loc
548548+ "[Ppat_unboxed_tuple] with an \"open\" pattern cannot be converted to an \
549549+ upstream [pattern_desc]"
550550+ | Ppat_unboxed_tuple (labeled_pats, Closed) ->
551551+ (match as_unlabeled_tuple labeled_pats with
552552+ | Some pats -> Ppat_tuple pats
553553+ | None ->
554554+ failwith
555555+ "[Ppat_unboxed_tuple], when labels are present, cannot be converted to an \
556556+ upstream [pattern_desc]")
557557+ | Ppat_record_unboxed_product (a, b) -> Ppat_record (a, b)
558558+ | Ppat_construct (a, b) ->
559559+ let b =
560560+ Option.map
561561+ (fun (vars, p) ->
562562+ let vars = List.map (fun (var, (_ : jkind_annotation option)) -> var) vars in
563563+ vars, p)
564564+ b
565565+ in
566566+ Ppat_construct (a, b)
567567+ (* unchanged constructors *)
568568+ | Ppat_any -> Ppat_any
569569+ | Ppat_var a -> Ppat_var a
570570+ | Ppat_alias (a, b) -> Ppat_alias (a, b)
571571+ | Ppat_constant a -> Ppat_constant a
572572+ | Ppat_interval (a, b) -> Ppat_interval (a, b)
573573+ | Ppat_variant (a, b) -> Ppat_variant (a, b)
574574+ | Ppat_record (a, b) -> Ppat_record (a, b)
575575+ | Ppat_or (a, b) -> Ppat_or (a, b)
576576+ | Ppat_type a -> Ppat_type a
577577+ | Ppat_lazy a -> Ppat_lazy a
578578+ | Ppat_unpack a -> Ppat_unpack a
579579+ | Ppat_exception a -> Ppat_exception a
580580+ | Ppat_extension a -> Ppat_extension a
581581+ | Ppat_open (a, b) -> Ppat_open (a, b)
582582+ ;;
583583+end
584584+585585+module Expression_desc = struct
586586+ type comprehension_expression = private
587587+ | Pcomp_list_comprehension of unit
588588+ | Pcomp_array_comprehension of unit
589589+590590+ type t =
591591+ | Pexp_ident of Longident.t loc
592592+ | Pexp_constant of constant
593593+ | Pexp_let of mutable_flag * rec_flag * value_binding list * expression
594594+ | Pexp_function of
595595+ Pexp_function.function_param list
596596+ * Pexp_function.Function_constraint.t
597597+ * Pexp_function.function_body
598598+ | Pexp_apply of expression * (arg_label * expression) list
599599+ | Pexp_match of expression * case list
600600+ | Pexp_try of expression * case list
601601+ | Pexp_tuple of (string option * expression) list
602602+ | Pexp_unboxed_tuple of (string option * expression) list
603603+ | Pexp_construct of Longident.t loc * expression option
604604+ | Pexp_variant of label * expression option
605605+ | Pexp_record of (Longident.t loc * expression) list * expression option
606606+ | Pexp_record_unboxed_product of
607607+ (Longident.t loc * expression) list * expression option
608608+ | Pexp_field of expression * Longident.t loc
609609+ | Pexp_unboxed_field of expression * Longident.t loc
610610+ | Pexp_setfield of expression * Longident.t loc * expression
611611+ | Pexp_array of mutable_flag * expression list
612612+ | Pexp_idx of block_access * unboxed_access list
613613+ | Pexp_ifthenelse of expression * expression * expression option
614614+ | Pexp_sequence of expression * expression
615615+ | Pexp_while of expression * expression
616616+ | Pexp_for of pattern * expression * expression * direction_flag * expression
617617+ | Pexp_constraint of expression * core_type option * Modes.t
618618+ | Pexp_coerce of expression * core_type option * core_type
619619+ | Pexp_send of expression * label loc
620620+ | Pexp_new of Longident.t loc
621621+ | Pexp_setvar of label loc * expression
622622+ | Pexp_override of (label loc * expression) list
623623+ | Pexp_letmodule of string option loc * module_expr * expression
624624+ | Pexp_letexception of extension_constructor * expression
625625+ | Pexp_assert of expression
626626+ | Pexp_lazy of expression
627627+ | Pexp_poly of expression * core_type option
628628+ | Pexp_object of class_structure
629629+ | Pexp_newtype of string loc * jkind_annotation option * expression
630630+ | Pexp_pack of module_expr
631631+ | Pexp_open of open_declaration * expression
632632+ | Pexp_letop of letop
633633+ | Pexp_extension of extension
634634+ | Pexp_unreachable
635635+ | Pexp_stack of expression
636636+ | Pexp_comprehension of comprehension_expression
637637+ | Pexp_overwrite of expression * expression
638638+ | Pexp_quote of expression
639639+ | Pexp_splice of expression
640640+ | Pexp_hole
641641+642642+ let to_parsetree : loc:Location.t -> t -> expression_desc =
643643+ fun ~loc -> function
644644+ (* changed constructors *)
645645+ | Pexp_function (x1, x2, x3) ->
646646+ Pexp_function.to_parsetree ~params:x1 ~constraint_:x2 ~body:x3
647647+ | Pexp_constraint (x1, Some x2, _) -> Pexp_constraint (x1, x2)
648648+ | Pexp_constraint (x1, None, _) -> Pexp_constraint (x1, ptyp_any)
649649+ | Pexp_tuple labeled_exps ->
650650+ Pexp_tuple (as_unlabeled_tuple_unconditionally labeled_exps)
651651+ | Pexp_newtype (x1, _, x2) -> Pexp_newtype (x1, x2)
652652+ | Pexp_array (Mutable, x) -> Pexp_array x
653653+ | Pexp_array (Immutable, _) ->
654654+ Location.raise_errorf
655655+ ~loc
656656+ "Immutable [Pexp_array] cannot be converted to an upstream [expression_desc]"
657657+ | Pexp_record_unboxed_product (x1, x2) -> Pexp_record (x1, x2)
658658+ | Pexp_unboxed_field (x1, x2) -> Pexp_field (x1, x2)
659659+ (* new constructors *)
660660+ | Pexp_unboxed_tuple labeled_exps ->
661661+ Pexp_tuple (as_unlabeled_tuple_unconditionally labeled_exps)
662662+ | Pexp_idx _ ->
663663+ Location.raise_errorf
664664+ ~loc
665665+ "[Pexp_idx] cannot be converted to an upstream [expression_desc]"
666666+ (* unchanged constructors *)
667667+ | Pexp_ident x -> Pexp_ident x
668668+ | Pexp_constant x -> Pexp_constant x
669669+ | Pexp_let (Immutable, x1, x2, x3) -> Pexp_let (x1, x2, x3)
670670+ | Pexp_let (Mutable, _, _, _) ->
671671+ Location.raise_errorf
672672+ ~loc
673673+ "Mutable [Pexp_let] cannot be converted to an upstream [expression_desc]"
674674+ | Pexp_apply (x1, x2) -> Pexp_apply (x1, x2)
675675+ | Pexp_match (x1, x2) -> Pexp_match (x1, x2)
676676+ | Pexp_try (x1, x2) -> Pexp_try (x1, x2)
677677+ | Pexp_construct (x1, x2) -> Pexp_construct (x1, x2)
678678+ | Pexp_variant (x1, x2) -> Pexp_variant (x1, x2)
679679+ | Pexp_record (x1, x2) -> Pexp_record (x1, x2)
680680+ | Pexp_field (x1, x2) -> Pexp_field (x1, x2)
681681+ | Pexp_setfield (x1, x2, x3) -> Pexp_setfield (x1, x2, x3)
682682+ | Pexp_ifthenelse (x1, x2, x3) -> Pexp_ifthenelse (x1, x2, x3)
683683+ | Pexp_sequence (x1, x2) -> Pexp_sequence (x1, x2)
684684+ | Pexp_while (x1, x2) -> Pexp_while (x1, x2)
685685+ | Pexp_for (x1, x2, x3, x4, x5) -> Pexp_for (x1, x2, x3, x4, x5)
686686+ | Pexp_coerce (x1, x2, x3) -> Pexp_coerce (x1, x2, x3)
687687+ | Pexp_send (x1, x2) -> Pexp_send (x1, x2)
688688+ | Pexp_new x -> Pexp_new x
689689+ | Pexp_setvar (x1, x2) -> Pexp_setinstvar (x1, x2)
690690+ | Pexp_override x -> Pexp_override x
691691+ | Pexp_letmodule (x1, x2, x3) -> Pexp_letmodule (x1, x2, x3)
692692+ | Pexp_letexception (x1, x2) -> Pexp_letexception (x1, x2)
693693+ | Pexp_assert x -> Pexp_assert x
694694+ | Pexp_lazy x -> Pexp_lazy x
695695+ | Pexp_poly (x1, x2) -> Pexp_poly (x1, x2)
696696+ | Pexp_object x -> Pexp_object x
697697+ | Pexp_pack x -> Pexp_pack x
698698+ | Pexp_open (x1, x2) -> Pexp_open (x1, x2)
699699+ | Pexp_letop x -> Pexp_letop x
700700+ | Pexp_extension x -> Pexp_extension x
701701+ | Pexp_unreachable -> Pexp_unreachable
702702+ | Pexp_stack { pexp_desc; pexp_attributes; pexp_loc = _; pexp_loc_stack = _ } ->
703703+ (match pexp_attributes with
704704+ | [] -> pexp_desc
705705+ | _ :: _ ->
706706+ Location.raise_errorf
707707+ ~loc
708708+ "[Pexp_stack] cannot be converted to an upstream [expression_desc] without \
709709+ erasing attributes")
710710+ | Pexp_comprehension _ ->
711711+ Location.raise_errorf
712712+ ~loc
713713+ "[Pexp_comprehension] cannot be converted to an upstream [expression_desc]"
714714+ | Pexp_overwrite _ ->
715715+ Location.raise_errorf
716716+ ~loc
717717+ "[Pexp_overwrite] cannot be converted to an upstream [expression_desc]"
718718+ | Pexp_quote _ ->
719719+ Location.raise_errorf
720720+ ~loc
721721+ "[Pexp_quote] cannot be converted to an upstream [expression_desc]"
722722+ | Pexp_splice _ ->
723723+ Location.raise_errorf
724724+ ~loc
725725+ "[Pexp_slice] cannot be converted to an upstream [expression_desc]"
726726+ | Pexp_hole ->
727727+ Pexp_assert
728728+ { pexp_desc = Pexp_construct ({ loc; txt = Lident "false" }, None)
729729+ ; pexp_loc = loc
730730+ ; pexp_loc_stack = []
731731+ ; pexp_attributes = []
732732+ }
733733+ ;;
734734+735735+ let of_parsetree (expr_desc : expression_desc) ~loc : t =
736736+ (* changed constructors *)
737737+ match Pexp_function.of_parsetree expr_desc ~loc with
738738+ | Some (x1, x2, x3) -> Pexp_function (x1, x2, x3)
739739+ | None ->
740740+ (match expr_desc with
741741+ | Pexp_function _ | Pexp_fun _ ->
742742+ (* matched by above call to [of_parsetree] *)
743743+ assert false
744744+ | Pexp_constraint (x1, x2) -> Pexp_constraint (x1, Some x2, [])
745745+ | Pexp_tuple x -> Pexp_tuple (add_none_labels x)
746746+ | Pexp_newtype (x1, x2) -> Pexp_newtype (x1, None, x2)
747747+ | Pexp_array x -> Pexp_array (Mutable, x)
748748+ (* unchanged constructors *)
749749+ | Pexp_ident x -> Pexp_ident x
750750+ | Pexp_constant x -> Pexp_constant x
751751+ | Pexp_let (x1, x2, x3) -> Pexp_let (Immutable, x1, x2, x3)
752752+ | Pexp_apply (x1, x2) -> Pexp_apply (x1, x2)
753753+ | Pexp_match (x1, x2) -> Pexp_match (x1, x2)
754754+ | Pexp_try (x1, x2) -> Pexp_try (x1, x2)
755755+ | Pexp_construct (x1, x2) -> Pexp_construct (x1, x2)
756756+ | Pexp_variant (x1, x2) -> Pexp_variant (x1, x2)
757757+ | Pexp_record (x1, x2) -> Pexp_record (x1, x2)
758758+ | Pexp_field (x1, x2) -> Pexp_field (x1, x2)
759759+ | Pexp_setfield (x1, x2, x3) -> Pexp_setfield (x1, x2, x3)
760760+ | Pexp_ifthenelse (x1, x2, x3) -> Pexp_ifthenelse (x1, x2, x3)
761761+ | Pexp_sequence (x1, x2) -> Pexp_sequence (x1, x2)
762762+ | Pexp_while (x1, x2) -> Pexp_while (x1, x2)
763763+ | Pexp_for (x1, x2, x3, x4, x5) -> Pexp_for (x1, x2, x3, x4, x5)
764764+ | Pexp_coerce (x1, x2, x3) -> Pexp_coerce (x1, x2, x3)
765765+ | Pexp_send (x1, x2) -> Pexp_send (x1, x2)
766766+ | Pexp_new x -> Pexp_new x
767767+ | Pexp_setinstvar (x1, x2) -> Pexp_setvar (x1, x2)
768768+ | Pexp_override x -> Pexp_override x
769769+ | Pexp_letmodule (x1, x2, x3) -> Pexp_letmodule (x1, x2, x3)
770770+ | Pexp_letexception (x1, x2) -> Pexp_letexception (x1, x2)
771771+ | Pexp_assert x -> Pexp_assert x
772772+ | Pexp_lazy x -> Pexp_lazy x
773773+ | Pexp_poly (x1, x2) -> Pexp_poly (x1, x2)
774774+ | Pexp_object x -> Pexp_object x
775775+ | Pexp_pack x -> Pexp_pack x
776776+ | Pexp_open (x1, x2) -> Pexp_open (x1, x2)
777777+ | Pexp_letop x -> Pexp_letop x
778778+ | Pexp_extension x -> Pexp_extension x
779779+ | Pexp_unreachable -> Pexp_unreachable)
780780+ ;;
781781+end
782782+783783+module Type_kind = struct
784784+ type t =
785785+ | Ptype_abstract
786786+ | Ptype_variant of constructor_declaration list
787787+ | Ptype_record of label_declaration list
788788+ | Ptype_record_unboxed_product of label_declaration list
789789+ | Ptype_open
790790+791791+ let of_parsetree : type_kind -> t = function
792792+ | Ptype_abstract -> Ptype_abstract
793793+ | Ptype_variant x -> Ptype_variant x
794794+ | Ptype_record x -> Ptype_record x
795795+ | Ptype_open -> Ptype_open
796796+ ;;
797797+798798+ let to_parsetree : t -> type_kind = function
799799+ | Ptype_abstract -> Ptype_abstract
800800+ | Ptype_variant x -> Ptype_variant x
801801+ | Ptype_record x -> Ptype_record x
802802+ | Ptype_record_unboxed_product x -> Ptype_record x
803803+ | Ptype_open -> Ptype_open
804804+ ;;
805805+end
806806+807807+module Constructor_declaration = struct
808808+ let extract_vars_with_jkind_annotations cd = List.map (fun s -> s, None) cd.pcd_vars
809809+810810+ let create ~name ~vars ~args ~res ~loc =
811811+ { pcd_name = name
812812+ ; pcd_vars = List.map fst vars
813813+ ; pcd_args = args
814814+ ; pcd_res = res
815815+ ; pcd_loc = loc
816816+ ; pcd_attributes = []
817817+ }
818818+ ;;
819819+end
820820+821821+module Include_infos = struct
822822+ type 'a t =
823823+ { pincl_kind : Include_kind.t
824824+ ; pincl_mod : 'a
825825+ ; pincl_loc : Location.t
826826+ ; pincl_attributes : attributes
827827+ }
828828+829829+ let of_parsetree x : 'a t =
830830+ let ({ pincl_mod; pincl_loc; pincl_attributes } : 'a include_infos) = x in
831831+ let pincl_kind : Include_kind.t = Structure in
832832+ { pincl_kind; pincl_mod; pincl_loc; pincl_attributes }
833833+ ;;
834834+835835+ let to_parsetree x : 'a include_infos =
836836+ let ({ pincl_kind; pincl_mod; pincl_loc; pincl_attributes } : 'a t) = x in
837837+ match pincl_kind with
838838+ | Structure -> { pincl_mod; pincl_loc; pincl_attributes }
839839+ | Functor ->
840840+ Location.raise_errorf
841841+ ~loc:pincl_loc
842842+ "[include functor] cannot be converted to an upstream [include_infos]"
843843+ ;;
844844+end
845845+846846+module Signature_item_desc = struct
847847+ type t =
848848+ | Psig_value of value_description
849849+ | Psig_type of rec_flag * type_declaration list
850850+ | Psig_typesubst of type_declaration list
851851+ | Psig_typext of type_extension
852852+ | Psig_exception of type_exception
853853+ | Psig_module of module_declaration
854854+ | Psig_modsubst of module_substitution
855855+ | Psig_recmodule of module_declaration list
856856+ | Psig_modtype of module_type_declaration
857857+ | Psig_modtypesubst of module_type_declaration
858858+ | Psig_open of open_description
859859+ | Psig_include of include_description * Modalities.t
860860+ | Psig_class of class_description list
861861+ | Psig_class_type of class_type_declaration list
862862+ | Psig_attribute of attribute
863863+ | Psig_extension of extension * attributes
864864+ | Psig_kind_abbrev of string loc * jkind_annotation
865865+866866+ let of_parsetree (sig_desc : signature_item_desc) =
867867+ match sig_desc with
868868+ | Psig_value a -> Psig_value a
869869+ | Psig_type (a, b) -> Psig_type (a, b)
870870+ | Psig_typesubst a -> Psig_typesubst a
871871+ | Psig_typext a -> Psig_typext a
872872+ | Psig_exception a -> Psig_exception a
873873+ | Psig_module a -> Psig_module a
874874+ | Psig_modsubst a -> Psig_modsubst a
875875+ | Psig_recmodule a -> Psig_recmodule a
876876+ | Psig_modtype a -> Psig_modtype a
877877+ | Psig_modtypesubst a -> Psig_modtypesubst a
878878+ | Psig_open a -> Psig_open a
879879+ | Psig_include a -> Psig_include (a, [])
880880+ | Psig_class a -> Psig_class a
881881+ | Psig_class_type a -> Psig_class_type a
882882+ | Psig_attribute a -> Psig_attribute a
883883+ | Psig_extension (a, b) -> Psig_extension (a, b)
884884+ ;;
885885+886886+ let to_parsetree (t : t) : signature_item_desc =
887887+ match t with
888888+ | Psig_value a -> Psig_value a
889889+ | Psig_type (a, b) -> Psig_type (a, b)
890890+ | Psig_typesubst a -> Psig_typesubst a
891891+ | Psig_typext a -> Psig_typext a
892892+ | Psig_exception a -> Psig_exception a
893893+ | Psig_module a -> Psig_module a
894894+ | Psig_modsubst a -> Psig_modsubst a
895895+ | Psig_recmodule a -> Psig_recmodule a
896896+ | Psig_modtype a -> Psig_modtype a
897897+ | Psig_modtypesubst a -> Psig_modtypesubst a
898898+ | Psig_open a -> Psig_open a
899899+ | Psig_include (a, _) -> Psig_include a
900900+ | Psig_class a -> Psig_class a
901901+ | Psig_class_type a -> Psig_class_type a
902902+ | Psig_attribute a -> Psig_attribute a
903903+ | Psig_extension (a, b) -> Psig_extension (a, b)
904904+ | Psig_kind_abbrev _ ->
905905+ (* erase to [include sig end] *)
906906+ Psig_include
907907+ { pincl_loc = Location.none
908908+ ; pincl_attributes = []
909909+ ; pincl_mod =
910910+ { pmty_desc = Pmty_signature []
911911+ ; pmty_loc = Location.none
912912+ ; pmty_attributes = []
913913+ }
914914+ }
915915+ ;;
916916+end
917917+918918+module Signature = struct
919919+ type t =
920920+ { psg_modalities : Modalities.t
921921+ ; psg_items : signature_item list
922922+ ; psg_loc : Location.t
923923+ }
924924+925925+ let of_parsetree psg_items = { psg_items; psg_modalities = []; psg_loc = Location.none }
926926+ let to_parsetree { psg_items; psg_modalities = _; psg_loc = _ } = psg_items
927927+end
928928+929929+module Structure_item_desc = struct
930930+ type t =
931931+ | Pstr_eval of expression * attributes
932932+ | Pstr_value of rec_flag * value_binding list
933933+ | Pstr_primitive of value_description
934934+ | Pstr_type of rec_flag * type_declaration list
935935+ | Pstr_typext of type_extension
936936+ | Pstr_exception of type_exception
937937+ | Pstr_module of module_binding
938938+ | Pstr_recmodule of module_binding list
939939+ | Pstr_modtype of module_type_declaration
940940+ | Pstr_open of open_declaration
941941+ | Pstr_class of class_declaration list
942942+ | Pstr_class_type of class_type_declaration list
943943+ | Pstr_include of include_declaration
944944+ | Pstr_attribute of attribute
945945+ | Pstr_extension of extension * attributes
946946+ | Pstr_kind_abbrev of string loc * jkind_annotation
947947+948948+ let of_parsetree : structure_item_desc -> t = function
949949+ | Pstr_eval (a, b) -> Pstr_eval (a, b)
950950+ | Pstr_value (a, b) -> Pstr_value (a, b)
951951+ | Pstr_primitive a -> Pstr_primitive a
952952+ | Pstr_type (a, b) -> Pstr_type (a, b)
953953+ | Pstr_typext a -> Pstr_typext a
954954+ | Pstr_exception a -> Pstr_exception a
955955+ | Pstr_module a -> Pstr_module a
956956+ | Pstr_recmodule a -> Pstr_recmodule a
957957+ | Pstr_modtype a -> Pstr_modtype a
958958+ | Pstr_open a -> Pstr_open a
959959+ | Pstr_class a -> Pstr_class a
960960+ | Pstr_class_type a -> Pstr_class_type a
961961+ | Pstr_include a -> Pstr_include a
962962+ | Pstr_attribute a -> Pstr_attribute a
963963+ | Pstr_extension (a, b) -> Pstr_extension (a, b)
964964+ ;;
965965+966966+ let to_parsetree : t -> structure_item_desc = function
967967+ | Pstr_eval (a, b) -> Pstr_eval (a, b)
968968+ | Pstr_value (a, b) -> Pstr_value (a, b)
969969+ | Pstr_primitive a -> Pstr_primitive a
970970+ | Pstr_type (a, b) -> Pstr_type (a, b)
971971+ | Pstr_typext a -> Pstr_typext a
972972+ | Pstr_exception a -> Pstr_exception a
973973+ | Pstr_module a -> Pstr_module a
974974+ | Pstr_recmodule a -> Pstr_recmodule a
975975+ | Pstr_modtype a -> Pstr_modtype a
976976+ | Pstr_open a -> Pstr_open a
977977+ | Pstr_class a -> Pstr_class a
978978+ | Pstr_class_type a -> Pstr_class_type a
979979+ | Pstr_include a -> Pstr_include a
980980+ | Pstr_attribute a -> Pstr_attribute a
981981+ | Pstr_extension (a, b) -> Pstr_extension (a, b)
982982+ | Pstr_kind_abbrev _ ->
983983+ (* erase to [include struct end] *)
984984+ Pstr_include
985985+ { pincl_loc = Location.none
986986+ ; pincl_attributes = []
987987+ ; pincl_mod =
988988+ { pmod_desc = Pmod_structure []
989989+ ; pmod_loc = Location.none
990990+ ; pmod_attributes = []
991991+ }
992992+ }
993993+ ;;
994994+end
995995+996996+module Functor_parameter = struct
997997+ type t =
998998+ | Unit
999999+ | Named of string option loc * module_type * Modes.t
10001000+10011001+ let to_parsetree (t : t) : functor_parameter =
10021002+ match t with
10031003+ | Unit -> Unit
10041004+ | Named (name, type_, _) -> Named (name, type_)
10051005+ ;;
10061006+10071007+ let of_parsetree (t : functor_parameter) : t =
10081008+ match t with
10091009+ | Unit -> Unit
10101010+ | Named (name, type_) -> Named (name, type_, [])
10111011+ ;;
10121012+end
10131013+10141014+module Module_type_desc = struct
10151015+ type t =
10161016+ | Pmty_ident of Longident.t loc
10171017+ | Pmty_signature of signature
10181018+ | Pmty_functor of functor_parameter * module_type * Modes.t
10191019+ | Pmty_with of module_type * with_constraint list
10201020+ | Pmty_typeof of module_expr
10211021+ | Pmty_extension of extension
10221022+ | Pmty_alias of Longident.t loc
10231023+ | Pmty_strengthen of module_type * Longident.t loc
10241024+10251025+ let of_parsetree : module_type_desc -> t = function
10261026+ | Pmty_ident x -> Pmty_ident x
10271027+ | Pmty_signature x -> Pmty_signature x
10281028+ | Pmty_functor (x0, x1) -> Pmty_functor (x0, x1, [])
10291029+ | Pmty_with (x0, x1) -> Pmty_with (x0, x1)
10301030+ | Pmty_typeof x -> Pmty_typeof x
10311031+ | Pmty_extension x -> Pmty_extension x
10321032+ | Pmty_alias x -> Pmty_alias x
10331033+ ;;
10341034+10351035+ let to_parsetree : loc:Location.t -> t -> module_type_desc =
10361036+ fun ~loc -> function
10371037+ (* new constructors *)
10381038+ | Pmty_strengthen _ ->
10391039+ Location.raise_errorf
10401040+ ~loc
10411041+ "[Pmty_strengthen] cannot be converted to an upstream [module_type_desc]"
10421042+ (* unchanged constructors *)
10431043+ | Pmty_ident x -> Pmty_ident x
10441044+ | Pmty_signature x -> Pmty_signature x
10451045+ | Pmty_functor (x0, x1, _) -> Pmty_functor (x0, x1)
10461046+ | Pmty_with (x0, x1) -> Pmty_with (x0, x1)
10471047+ | Pmty_typeof x -> Pmty_typeof x
10481048+ | Pmty_extension x -> Pmty_extension x
10491049+ | Pmty_alias x -> Pmty_alias x
10501050+ ;;
10511051+end
10521052+10531053+module Module_expr_desc = struct
10541054+ type module_instance = private Module_instance
10551055+10561056+ type t =
10571057+ | Pmod_ident of Longident.t loc
10581058+ | Pmod_structure of structure
10591059+ | Pmod_functor of functor_parameter * module_expr
10601060+ | Pmod_apply of module_expr * module_expr
10611061+ | Pmod_constraint of module_expr * module_type option * Modes.t
10621062+ | Pmod_unpack of expression
10631063+ | Pmod_extension of extension
10641064+ | Pmod_instance of module_instance
10651065+10661066+ let of_parsetree : module_expr_desc -> t = function
10671067+ | Pmod_ident x -> Pmod_ident x
10681068+ | Pmod_structure x -> Pmod_structure x
10691069+ | Pmod_functor (x0, x1) -> Pmod_functor (x0, x1)
10701070+ | Pmod_apply (x0, x1) -> Pmod_apply (x0, x1)
10711071+ | Pmod_constraint (x0, x1) -> Pmod_constraint (x0, Some x1, [])
10721072+ | Pmod_unpack x -> Pmod_unpack x
10731073+ | Pmod_extension x -> Pmod_extension x
10741074+ ;;
10751075+10761076+ let to_parsetree : loc:Location.t -> t -> module_expr_desc =
10771077+ fun ~loc -> function
10781078+ (* new constructors *)
10791079+ | Pmod_instance _ ->
10801080+ Location.raise_errorf
10811081+ ~loc
10821082+ "[Pmod_instance] cannot be converted to an upstream [module_expr_desc]"
10831083+ (* unchanged constructors *)
10841084+ | Pmod_ident x -> Pmod_ident x
10851085+ | Pmod_structure x -> Pmod_structure x
10861086+ | Pmod_functor (x0, x1) -> Pmod_functor (x0, x1)
10871087+ | Pmod_apply (x0, x1) -> Pmod_apply (x0, x1)
10881088+ | Pmod_constraint (x0, x1, _) ->
10891089+ (match x1 with
10901090+ | Some x1 -> Pmod_constraint (x0, x1)
10911091+ | None ->
10921092+ (match x0 with
10931093+ | { pmod_desc; pmod_loc = _; pmod_attributes = [] } -> pmod_desc
10941094+ | { pmod_attributes = _ :: _; _ } ->
10951095+ Location.raise_errorf
10961096+ ~loc
10971097+ "[Pmod_constraint] without type cannot be converted to an upstream \
10981098+ [module_expr_desc] without erasing attributes"))
10991099+ | Pmod_unpack x -> Pmod_unpack x
11001100+ | Pmod_extension x -> Pmod_extension x
11011101+ ;;
11021102+end
11031103+11041104+module Ast_traverse = struct
11051105+ module Deriving_inline = struct
11061106+ type location = Location.t
11071107+11081108+ type jkind_annotation_desc = T.jkind_annotation_desc =
11091109+ | Pjk_default
11101110+ | Pjk_abbreviation of string
11111111+ | Pjk_mod of jkind_annotation * modes
11121112+ | Pjk_with of jkind_annotation * core_type * modalities
11131113+ | Pjk_kind_of of core_type
11141114+ | Pjk_product of jkind_annotation list
11151115+11161116+ and jkind_annotation = T.jkind_annotation =
11171117+ { pjkind_loc : location
11181118+ ; pjkind_desc : jkind_annotation_desc
11191119+ }
11201120+11211121+ and function_param_desc = Pexp_function.function_param_desc =
11221122+ | Pparam_val of arg_label * expression option * pattern
11231123+ | Pparam_newtype of string loc * jkind_annotation option
11241124+11251125+ and function_param = Pexp_function.function_param =
11261126+ { pparam_loc : location
11271127+ ; pparam_desc : function_param_desc
11281128+ }
11291129+11301130+ and type_constraint = Pexp_function.type_constraint =
11311131+ | Pconstraint of core_type
11321132+ | Pcoerce of core_type option * core_type
11331133+11341134+ and function_constraint = Pexp_function.Function_constraint.t =
11351135+ { mode_annotations : modes
11361136+ ; ret_mode_annotations : modes
11371137+ ; ret_type_constraint : type_constraint option
11381138+ }
11391139+11401140+ and function_body = Pexp_function.function_body =
11411141+ | Pfunction_body of expression
11421142+ | Pfunction_cases of case list * location * attributes
11431143+11441144+ and mode = Mode.t = Mode of string [@@unboxed]
11451145+ and modes = mode loc list
11461146+ and modality = Modality.t = Modality of string [@@unboxed]
11471147+ and modalities = modality loc list
11481148+ and signature_items = signature_item list
11491149+ and signature = signature_items [@@deriving_inline traverse]
11501150+11511151+ class virtual map =
11521152+ object (self)
11531153+ method virtual arg_label : arg_label -> arg_label
11541154+ method virtual attributes : attributes -> attributes
11551155+ method virtual case : case -> case
11561156+ method virtual core_type : core_type -> core_type
11571157+ method virtual expression : expression -> expression
11581158+ method virtual list : 'a. ('a -> 'a) -> 'a list -> 'a list
11591159+ method virtual loc : 'a. ('a -> 'a) -> 'a loc -> 'a loc
11601160+ method virtual location : location -> location
11611161+ method virtual option : 'a. ('a -> 'a) -> 'a option -> 'a option
11621162+ method virtual pattern : pattern -> pattern
11631163+ method virtual signature_item : signature_item -> signature_item
11641164+ method virtual string : string -> string
11651165+11661166+ method jkind_annotation_desc : jkind_annotation_desc -> jkind_annotation_desc =
11671167+ fun x ->
11681168+ match x with
11691169+ | Pjk_default -> Pjk_default
11701170+ | Pjk_abbreviation a ->
11711171+ let a = self#string a in
11721172+ Pjk_abbreviation a
11731173+ | Pjk_mod (a, b) ->
11741174+ let a = self#jkind_annotation a in
11751175+ let b = self#modes b in
11761176+ Pjk_mod (a, b)
11771177+ | Pjk_with (a, b, c) ->
11781178+ let a = self#jkind_annotation a in
11791179+ let b = self#core_type b in
11801180+ let c = self#modalities c in
11811181+ Pjk_with (a, b, c)
11821182+ | Pjk_kind_of a ->
11831183+ let a = self#core_type a in
11841184+ Pjk_kind_of a
11851185+ | Pjk_product a ->
11861186+ let a = self#list self#jkind_annotation a in
11871187+ Pjk_product a
11881188+11891189+ method jkind_annotation : jkind_annotation -> jkind_annotation =
11901190+ fun { pjkind_loc; pjkind_desc } ->
11911191+ let pjkind_loc = self#location pjkind_loc in
11921192+ let pjkind_desc = self#jkind_annotation_desc pjkind_desc in
11931193+ { pjkind_loc; pjkind_desc }
11941194+11951195+ method function_param_desc : function_param_desc -> function_param_desc =
11961196+ fun x ->
11971197+ match x with
11981198+ | Pparam_val (a, b, c) ->
11991199+ let a = self#arg_label a in
12001200+ let b = self#option self#expression b in
12011201+ let c = self#pattern c in
12021202+ Pparam_val (a, b, c)
12031203+ | Pparam_newtype (a, b) ->
12041204+ let a = self#loc self#string a in
12051205+ let b = self#option self#jkind_annotation b in
12061206+ Pparam_newtype (a, b)
12071207+12081208+ method function_param : function_param -> function_param =
12091209+ fun { pparam_loc; pparam_desc } ->
12101210+ let pparam_loc = self#location pparam_loc in
12111211+ let pparam_desc = self#function_param_desc pparam_desc in
12121212+ { pparam_loc; pparam_desc }
12131213+12141214+ method type_constraint : type_constraint -> type_constraint =
12151215+ fun x ->
12161216+ match x with
12171217+ | Pconstraint a ->
12181218+ let a = self#core_type a in
12191219+ Pconstraint a
12201220+ | Pcoerce (a, b) ->
12211221+ let a = self#option self#core_type a in
12221222+ let b = self#core_type b in
12231223+ Pcoerce (a, b)
12241224+12251225+ method function_constraint : function_constraint -> function_constraint =
12261226+ fun { mode_annotations; ret_mode_annotations; ret_type_constraint } ->
12271227+ let mode_annotations = self#modes mode_annotations in
12281228+ let ret_mode_annotations = self#modes ret_mode_annotations in
12291229+ let ret_type_constraint =
12301230+ self#option self#type_constraint ret_type_constraint
12311231+ in
12321232+ { mode_annotations; ret_mode_annotations; ret_type_constraint }
12331233+12341234+ method function_body : function_body -> function_body =
12351235+ fun x ->
12361236+ match x with
12371237+ | Pfunction_body a ->
12381238+ let a = self#expression a in
12391239+ Pfunction_body a
12401240+ | Pfunction_cases (a, b, c) ->
12411241+ let a = self#list self#case a in
12421242+ let b = self#location b in
12431243+ let c = self#attributes c in
12441244+ Pfunction_cases (a, b, c)
12451245+12461246+ method mode : mode -> mode =
12471247+ fun x ->
12481248+ match x with
12491249+ | Mode a ->
12501250+ let a = self#string a in
12511251+ Mode a
12521252+12531253+ method modes : modes -> modes = self#list (self#loc self#mode)
12541254+12551255+ method modality : modality -> modality =
12561256+ fun x ->
12571257+ match x with
12581258+ | Modality a ->
12591259+ let a = self#string a in
12601260+ Modality a
12611261+12621262+ method modalities : modalities -> modalities = self#list (self#loc self#modality)
12631263+12641264+ method signature_items : signature_items -> signature_items =
12651265+ self#list self#signature_item
12661266+12671267+ method signature : signature -> signature = self#signature_items
12681268+ end
12691269+12701270+ class virtual iter =
12711271+ object (self)
12721272+ method virtual arg_label : arg_label -> unit
12731273+ method virtual attributes : attributes -> unit
12741274+ method virtual case : case -> unit
12751275+ method virtual core_type : core_type -> unit
12761276+ method virtual expression : expression -> unit
12771277+ method virtual list : 'a. ('a -> unit) -> 'a list -> unit
12781278+ method virtual loc : 'a. ('a -> unit) -> 'a loc -> unit
12791279+ method virtual location : location -> unit
12801280+ method virtual option : 'a. ('a -> unit) -> 'a option -> unit
12811281+ method virtual pattern : pattern -> unit
12821282+ method virtual signature_item : signature_item -> unit
12831283+ method virtual string : string -> unit
12841284+12851285+ method jkind_annotation_desc : jkind_annotation_desc -> unit =
12861286+ fun x ->
12871287+ match x with
12881288+ | Pjk_default -> ()
12891289+ | Pjk_abbreviation a -> self#string a
12901290+ | Pjk_mod (a, b) ->
12911291+ self#jkind_annotation a;
12921292+ self#modes b
12931293+ | Pjk_with (a, b, c) ->
12941294+ self#jkind_annotation a;
12951295+ self#core_type b;
12961296+ self#modalities c
12971297+ | Pjk_kind_of a -> self#core_type a
12981298+ | Pjk_product a -> self#list self#jkind_annotation a
12991299+13001300+ method jkind_annotation : jkind_annotation -> unit =
13011301+ fun { pjkind_loc; pjkind_desc } ->
13021302+ self#location pjkind_loc;
13031303+ self#jkind_annotation_desc pjkind_desc
13041304+13051305+ method function_param_desc : function_param_desc -> unit =
13061306+ fun x ->
13071307+ match x with
13081308+ | Pparam_val (a, b, c) ->
13091309+ self#arg_label a;
13101310+ self#option self#expression b;
13111311+ self#pattern c
13121312+ | Pparam_newtype (a, b) ->
13131313+ self#loc self#string a;
13141314+ self#option self#jkind_annotation b
13151315+13161316+ method function_param : function_param -> unit =
13171317+ fun { pparam_loc; pparam_desc } ->
13181318+ self#location pparam_loc;
13191319+ self#function_param_desc pparam_desc
13201320+13211321+ method type_constraint : type_constraint -> unit =
13221322+ fun x ->
13231323+ match x with
13241324+ | Pconstraint a -> self#core_type a
13251325+ | Pcoerce (a, b) ->
13261326+ self#option self#core_type a;
13271327+ self#core_type b
13281328+13291329+ method function_constraint : function_constraint -> unit =
13301330+ fun { mode_annotations; ret_mode_annotations; ret_type_constraint } ->
13311331+ self#modes mode_annotations;
13321332+ self#modes ret_mode_annotations;
13331333+ self#option self#type_constraint ret_type_constraint
13341334+13351335+ method function_body : function_body -> unit =
13361336+ fun x ->
13371337+ match x with
13381338+ | Pfunction_body a -> self#expression a
13391339+ | Pfunction_cases (a, b, c) ->
13401340+ self#list self#case a;
13411341+ self#location b;
13421342+ self#attributes c
13431343+13441344+ method mode : mode -> unit =
13451345+ fun x ->
13461346+ match x with
13471347+ | Mode a -> self#string a
13481348+13491349+ method modes : modes -> unit = self#list (self#loc self#mode)
13501350+13511351+ method modality : modality -> unit =
13521352+ fun x ->
13531353+ match x with
13541354+ | Modality a -> self#string a
13551355+13561356+ method modalities : modalities -> unit = self#list (self#loc self#modality)
13571357+ method signature_items : signature_items -> unit = self#list self#signature_item
13581358+ method signature : signature -> unit = self#signature_items
13591359+ end
13601360+13611361+ class virtual ['acc] fold =
13621362+ object (self)
13631363+ method virtual arg_label : arg_label -> 'acc -> 'acc
13641364+ method virtual attributes : attributes -> 'acc -> 'acc
13651365+ method virtual case : case -> 'acc -> 'acc
13661366+ method virtual core_type : core_type -> 'acc -> 'acc
13671367+ method virtual expression : expression -> 'acc -> 'acc
13681368+ method virtual list : 'a. ('a -> 'acc -> 'acc) -> 'a list -> 'acc -> 'acc
13691369+ method virtual loc : 'a. ('a -> 'acc -> 'acc) -> 'a loc -> 'acc -> 'acc
13701370+ method virtual location : location -> 'acc -> 'acc
13711371+ method virtual option : 'a. ('a -> 'acc -> 'acc) -> 'a option -> 'acc -> 'acc
13721372+ method virtual pattern : pattern -> 'acc -> 'acc
13731373+ method virtual signature_item : signature_item -> 'acc -> 'acc
13741374+ method virtual string : string -> 'acc -> 'acc
13751375+13761376+ method jkind_annotation_desc : jkind_annotation_desc -> 'acc -> 'acc =
13771377+ fun x acc ->
13781378+ match x with
13791379+ | Pjk_default -> acc
13801380+ | Pjk_abbreviation a -> self#string a acc
13811381+ | Pjk_mod (a, b) ->
13821382+ let acc = self#jkind_annotation a acc in
13831383+ let acc = self#modes b acc in
13841384+ acc
13851385+ | Pjk_with (a, b, c) ->
13861386+ let acc = self#jkind_annotation a acc in
13871387+ let acc = self#core_type b acc in
13881388+ let acc = self#modalities c acc in
13891389+ acc
13901390+ | Pjk_kind_of a -> self#core_type a acc
13911391+ | Pjk_product a -> self#list self#jkind_annotation a acc
13921392+13931393+ method jkind_annotation : jkind_annotation -> 'acc -> 'acc =
13941394+ fun { pjkind_loc; pjkind_desc } acc ->
13951395+ let acc = self#location pjkind_loc acc in
13961396+ let acc = self#jkind_annotation_desc pjkind_desc acc in
13971397+ acc
13981398+13991399+ method function_param_desc : function_param_desc -> 'acc -> 'acc =
14001400+ fun x acc ->
14011401+ match x with
14021402+ | Pparam_val (a, b, c) ->
14031403+ let acc = self#arg_label a acc in
14041404+ let acc = self#option self#expression b acc in
14051405+ let acc = self#pattern c acc in
14061406+ acc
14071407+ | Pparam_newtype (a, b) ->
14081408+ let acc = self#loc self#string a acc in
14091409+ let acc = self#option self#jkind_annotation b acc in
14101410+ acc
14111411+14121412+ method function_param : function_param -> 'acc -> 'acc =
14131413+ fun { pparam_loc; pparam_desc } acc ->
14141414+ let acc = self#location pparam_loc acc in
14151415+ let acc = self#function_param_desc pparam_desc acc in
14161416+ acc
14171417+14181418+ method type_constraint : type_constraint -> 'acc -> 'acc =
14191419+ fun x acc ->
14201420+ match x with
14211421+ | Pconstraint a -> self#core_type a acc
14221422+ | Pcoerce (a, b) ->
14231423+ let acc = self#option self#core_type a acc in
14241424+ let acc = self#core_type b acc in
14251425+ acc
14261426+14271427+ method function_constraint : function_constraint -> 'acc -> 'acc =
14281428+ fun { mode_annotations; ret_mode_annotations; ret_type_constraint } acc ->
14291429+ let acc = self#modes mode_annotations acc in
14301430+ let acc = self#modes ret_mode_annotations acc in
14311431+ let acc = self#option self#type_constraint ret_type_constraint acc in
14321432+ acc
14331433+14341434+ method function_body : function_body -> 'acc -> 'acc =
14351435+ fun x acc ->
14361436+ match x with
14371437+ | Pfunction_body a -> self#expression a acc
14381438+ | Pfunction_cases (a, b, c) ->
14391439+ let acc = self#list self#case a acc in
14401440+ let acc = self#location b acc in
14411441+ let acc = self#attributes c acc in
14421442+ acc
14431443+14441444+ method mode : mode -> 'acc -> 'acc =
14451445+ fun x acc ->
14461446+ match x with
14471447+ | Mode a -> self#string a acc
14481448+14491449+ method modes : modes -> 'acc -> 'acc = self#list (self#loc self#mode)
14501450+14511451+ method modality : modality -> 'acc -> 'acc =
14521452+ fun x acc ->
14531453+ match x with
14541454+ | Modality a -> self#string a acc
14551455+14561456+ method modalities : modalities -> 'acc -> 'acc =
14571457+ self#list (self#loc self#modality)
14581458+14591459+ method signature_items : signature_items -> 'acc -> 'acc =
14601460+ self#list self#signature_item
14611461+14621462+ method signature : signature -> 'acc -> 'acc = self#signature_items
14631463+ end
14641464+14651465+ class virtual ['acc] fold_map =
14661466+ object (self)
14671467+ method virtual arg_label : arg_label -> 'acc -> arg_label * 'acc
14681468+ method virtual attributes : attributes -> 'acc -> attributes * 'acc
14691469+ method virtual case : case -> 'acc -> case * 'acc
14701470+ method virtual core_type : core_type -> 'acc -> core_type * 'acc
14711471+ method virtual expression : expression -> 'acc -> expression * 'acc
14721472+14731473+ method
14741474+ virtual list
14751475+ : 'a. ('a -> 'acc -> 'a * 'acc) -> 'a list -> 'acc -> 'a list * 'acc
14761476+14771477+ method
14781478+ virtual loc
14791479+ : 'a. ('a -> 'acc -> 'a * 'acc) -> 'a loc -> 'acc -> 'a loc * 'acc
14801480+14811481+ method virtual location : location -> 'acc -> location * 'acc
14821482+14831483+ method
14841484+ virtual option
14851485+ : 'a. ('a -> 'acc -> 'a * 'acc) -> 'a option -> 'acc -> 'a option * 'acc
14861486+14871487+ method virtual pattern : pattern -> 'acc -> pattern * 'acc
14881488+ method virtual signature_item : signature_item -> 'acc -> signature_item * 'acc
14891489+ method virtual string : string -> 'acc -> string * 'acc
14901490+14911491+ method jkind_annotation_desc
14921492+ : jkind_annotation_desc -> 'acc -> jkind_annotation_desc * 'acc =
14931493+ fun x acc ->
14941494+ match x with
14951495+ | Pjk_default -> Pjk_default, acc
14961496+ | Pjk_abbreviation a ->
14971497+ let a, acc = self#string a acc in
14981498+ Pjk_abbreviation a, acc
14991499+ | Pjk_mod (a, b) ->
15001500+ let a, acc = self#jkind_annotation a acc in
15011501+ let b, acc = self#modes b acc in
15021502+ Pjk_mod (a, b), acc
15031503+ | Pjk_with (a, b, c) ->
15041504+ let a, acc = self#jkind_annotation a acc in
15051505+ let b, acc = self#core_type b acc in
15061506+ let c, acc = self#modalities c acc in
15071507+ Pjk_with (a, b, c), acc
15081508+ | Pjk_kind_of a ->
15091509+ let a, acc = self#core_type a acc in
15101510+ Pjk_kind_of a, acc
15111511+ | Pjk_product a ->
15121512+ let a, acc = self#list self#jkind_annotation a acc in
15131513+ Pjk_product a, acc
15141514+15151515+ method jkind_annotation : jkind_annotation -> 'acc -> jkind_annotation * 'acc =
15161516+ fun { pjkind_loc; pjkind_desc } acc ->
15171517+ let pjkind_loc, acc = self#location pjkind_loc acc in
15181518+ let pjkind_desc, acc = self#jkind_annotation_desc pjkind_desc acc in
15191519+ { pjkind_loc; pjkind_desc }, acc
15201520+15211521+ method function_param_desc
15221522+ : function_param_desc -> 'acc -> function_param_desc * 'acc =
15231523+ fun x acc ->
15241524+ match x with
15251525+ | Pparam_val (a, b, c) ->
15261526+ let a, acc = self#arg_label a acc in
15271527+ let b, acc = self#option self#expression b acc in
15281528+ let c, acc = self#pattern c acc in
15291529+ Pparam_val (a, b, c), acc
15301530+ | Pparam_newtype (a, b) ->
15311531+ let a, acc = self#loc self#string a acc in
15321532+ let b, acc = self#option self#jkind_annotation b acc in
15331533+ Pparam_newtype (a, b), acc
15341534+15351535+ method function_param : function_param -> 'acc -> function_param * 'acc =
15361536+ fun { pparam_loc; pparam_desc } acc ->
15371537+ let pparam_loc, acc = self#location pparam_loc acc in
15381538+ let pparam_desc, acc = self#function_param_desc pparam_desc acc in
15391539+ { pparam_loc; pparam_desc }, acc
15401540+15411541+ method type_constraint : type_constraint -> 'acc -> type_constraint * 'acc =
15421542+ fun x acc ->
15431543+ match x with
15441544+ | Pconstraint a ->
15451545+ let a, acc = self#core_type a acc in
15461546+ Pconstraint a, acc
15471547+ | Pcoerce (a, b) ->
15481548+ let a, acc = self#option self#core_type a acc in
15491549+ let b, acc = self#core_type b acc in
15501550+ Pcoerce (a, b), acc
15511551+15521552+ method function_constraint
15531553+ : function_constraint -> 'acc -> function_constraint * 'acc =
15541554+ fun { mode_annotations; ret_mode_annotations; ret_type_constraint } acc ->
15551555+ let mode_annotations, acc = self#modes mode_annotations acc in
15561556+ let ret_mode_annotations, acc = self#modes ret_mode_annotations acc in
15571557+ let ret_type_constraint, acc =
15581558+ self#option self#type_constraint ret_type_constraint acc
15591559+ in
15601560+ { mode_annotations; ret_mode_annotations; ret_type_constraint }, acc
15611561+15621562+ method function_body : function_body -> 'acc -> function_body * 'acc =
15631563+ fun x acc ->
15641564+ match x with
15651565+ | Pfunction_body a ->
15661566+ let a, acc = self#expression a acc in
15671567+ Pfunction_body a, acc
15681568+ | Pfunction_cases (a, b, c) ->
15691569+ let a, acc = self#list self#case a acc in
15701570+ let b, acc = self#location b acc in
15711571+ let c, acc = self#attributes c acc in
15721572+ Pfunction_cases (a, b, c), acc
15731573+15741574+ method mode : mode -> 'acc -> mode * 'acc =
15751575+ fun x acc ->
15761576+ match x with
15771577+ | Mode a ->
15781578+ let a, acc = self#string a acc in
15791579+ Mode a, acc
15801580+15811581+ method modes : modes -> 'acc -> modes * 'acc = self#list (self#loc self#mode)
15821582+15831583+ method modality : modality -> 'acc -> modality * 'acc =
15841584+ fun x acc ->
15851585+ match x with
15861586+ | Modality a ->
15871587+ let a, acc = self#string a acc in
15881588+ Modality a, acc
15891589+15901590+ method modalities : modalities -> 'acc -> modalities * 'acc =
15911591+ self#list (self#loc self#modality)
15921592+15931593+ method signature_items : signature_items -> 'acc -> signature_items * 'acc =
15941594+ self#list self#signature_item
15951595+15961596+ method signature : signature -> 'acc -> signature * 'acc = self#signature_items
15971597+ end
15981598+15991599+ class virtual ['ctx] map_with_context =
16001600+ object (self)
16011601+ method virtual arg_label : 'ctx -> arg_label -> arg_label
16021602+ method virtual attributes : 'ctx -> attributes -> attributes
16031603+ method virtual case : 'ctx -> case -> case
16041604+ method virtual core_type : 'ctx -> core_type -> core_type
16051605+ method virtual expression : 'ctx -> expression -> expression
16061606+ method virtual list : 'a. ('ctx -> 'a -> 'a) -> 'ctx -> 'a list -> 'a list
16071607+ method virtual loc : 'a. ('ctx -> 'a -> 'a) -> 'ctx -> 'a loc -> 'a loc
16081608+ method virtual location : 'ctx -> location -> location
16091609+ method virtual option : 'a. ('ctx -> 'a -> 'a) -> 'ctx -> 'a option -> 'a option
16101610+ method virtual pattern : 'ctx -> pattern -> pattern
16111611+ method virtual signature_item : 'ctx -> signature_item -> signature_item
16121612+ method virtual string : 'ctx -> string -> string
16131613+16141614+ method jkind_annotation_desc
16151615+ : 'ctx -> jkind_annotation_desc -> jkind_annotation_desc =
16161616+ fun ctx x ->
16171617+ match x with
16181618+ | Pjk_default -> Pjk_default
16191619+ | Pjk_abbreviation a ->
16201620+ let a = self#string ctx a in
16211621+ Pjk_abbreviation a
16221622+ | Pjk_mod (a, b) ->
16231623+ let a = self#jkind_annotation ctx a in
16241624+ let b = self#modes ctx b in
16251625+ Pjk_mod (a, b)
16261626+ | Pjk_with (a, b, c) ->
16271627+ let a = self#jkind_annotation ctx a in
16281628+ let b = self#core_type ctx b in
16291629+ let c = self#modalities ctx c in
16301630+ Pjk_with (a, b, c)
16311631+ | Pjk_kind_of a ->
16321632+ let a = self#core_type ctx a in
16331633+ Pjk_kind_of a
16341634+ | Pjk_product a ->
16351635+ let a = self#list self#jkind_annotation ctx a in
16361636+ Pjk_product a
16371637+16381638+ method jkind_annotation : 'ctx -> jkind_annotation -> jkind_annotation =
16391639+ fun ctx { pjkind_loc; pjkind_desc } ->
16401640+ let pjkind_loc = self#location ctx pjkind_loc in
16411641+ let pjkind_desc = self#jkind_annotation_desc ctx pjkind_desc in
16421642+ { pjkind_loc; pjkind_desc }
16431643+16441644+ method function_param_desc : 'ctx -> function_param_desc -> function_param_desc =
16451645+ fun ctx x ->
16461646+ match x with
16471647+ | Pparam_val (a, b, c) ->
16481648+ let a = self#arg_label ctx a in
16491649+ let b = self#option self#expression ctx b in
16501650+ let c = self#pattern ctx c in
16511651+ Pparam_val (a, b, c)
16521652+ | Pparam_newtype (a, b) ->
16531653+ let a = self#loc self#string ctx a in
16541654+ let b = self#option self#jkind_annotation ctx b in
16551655+ Pparam_newtype (a, b)
16561656+16571657+ method function_param : 'ctx -> function_param -> function_param =
16581658+ fun ctx { pparam_loc; pparam_desc } ->
16591659+ let pparam_loc = self#location ctx pparam_loc in
16601660+ let pparam_desc = self#function_param_desc ctx pparam_desc in
16611661+ { pparam_loc; pparam_desc }
16621662+16631663+ method type_constraint : 'ctx -> type_constraint -> type_constraint =
16641664+ fun ctx x ->
16651665+ match x with
16661666+ | Pconstraint a ->
16671667+ let a = self#core_type ctx a in
16681668+ Pconstraint a
16691669+ | Pcoerce (a, b) ->
16701670+ let a = self#option self#core_type ctx a in
16711671+ let b = self#core_type ctx b in
16721672+ Pcoerce (a, b)
16731673+16741674+ method function_constraint : 'ctx -> function_constraint -> function_constraint =
16751675+ fun ctx { mode_annotations; ret_mode_annotations; ret_type_constraint } ->
16761676+ let mode_annotations = self#modes ctx mode_annotations in
16771677+ let ret_mode_annotations = self#modes ctx ret_mode_annotations in
16781678+ let ret_type_constraint =
16791679+ self#option self#type_constraint ctx ret_type_constraint
16801680+ in
16811681+ { mode_annotations; ret_mode_annotations; ret_type_constraint }
16821682+16831683+ method function_body : 'ctx -> function_body -> function_body =
16841684+ fun ctx x ->
16851685+ match x with
16861686+ | Pfunction_body a ->
16871687+ let a = self#expression ctx a in
16881688+ Pfunction_body a
16891689+ | Pfunction_cases (a, b, c) ->
16901690+ let a = self#list self#case ctx a in
16911691+ let b = self#location ctx b in
16921692+ let c = self#attributes ctx c in
16931693+ Pfunction_cases (a, b, c)
16941694+16951695+ method mode : 'ctx -> mode -> mode =
16961696+ fun ctx x ->
16971697+ match x with
16981698+ | Mode a ->
16991699+ let a = self#string ctx a in
17001700+ Mode a
17011701+17021702+ method modes : 'ctx -> modes -> modes = self#list (self#loc self#mode)
17031703+17041704+ method modality : 'ctx -> modality -> modality =
17051705+ fun ctx x ->
17061706+ match x with
17071707+ | Modality a ->
17081708+ let a = self#string ctx a in
17091709+ Modality a
17101710+17111711+ method modalities : 'ctx -> modalities -> modalities =
17121712+ self#list (self#loc self#modality)
17131713+17141714+ method signature_items : 'ctx -> signature_items -> signature_items =
17151715+ self#list self#signature_item
17161716+17171717+ method signature : 'ctx -> signature -> signature = self#signature_items
17181718+ end
17191719+17201720+ class virtual ['res] lift =
17211721+ object (self)
17221722+ method virtual record : (string * 'res) list -> 'res
17231723+ method virtual constr : string -> 'res list -> 'res
17241724+ method virtual arg_label : arg_label -> 'res
17251725+ method virtual attributes : attributes -> 'res
17261726+ method virtual case : case -> 'res
17271727+ method virtual core_type : core_type -> 'res
17281728+ method virtual expression : expression -> 'res
17291729+ method virtual list : 'a. ('a -> 'res) -> 'a list -> 'res
17301730+ method virtual loc : 'a. ('a -> 'res) -> 'a loc -> 'res
17311731+ method virtual location : location -> 'res
17321732+ method virtual option : 'a. ('a -> 'res) -> 'a option -> 'res
17331733+ method virtual pattern : pattern -> 'res
17341734+ method virtual signature_item : signature_item -> 'res
17351735+ method virtual string : string -> 'res
17361736+17371737+ method jkind_annotation_desc : jkind_annotation_desc -> 'res =
17381738+ fun x ->
17391739+ match x with
17401740+ | Pjk_default -> self#constr "Pjk_default" []
17411741+ | Pjk_abbreviation a ->
17421742+ let a = self#string a in
17431743+ self#constr "Pjk_abbreviation" [ a ]
17441744+ | Pjk_mod (a, b) ->
17451745+ let a = self#jkind_annotation a in
17461746+ let b = self#modes b in
17471747+ self#constr "Pjk_mod" [ a; b ]
17481748+ | Pjk_with (a, b, c) ->
17491749+ let a = self#jkind_annotation a in
17501750+ let b = self#core_type b in
17511751+ let c = self#modalities c in
17521752+ self#constr "Pjk_with" [ a; b; c ]
17531753+ | Pjk_kind_of a ->
17541754+ let a = self#core_type a in
17551755+ self#constr "Pjk_kind_of" [ a ]
17561756+ | Pjk_product a ->
17571757+ let a = self#list self#jkind_annotation a in
17581758+ self#constr "Pjk_product" [ a ]
17591759+17601760+ method jkind_annotation : jkind_annotation -> 'res =
17611761+ fun { pjkind_loc; pjkind_desc } ->
17621762+ let pjkind_loc = self#location pjkind_loc in
17631763+ let pjkind_desc = self#jkind_annotation_desc pjkind_desc in
17641764+ self#record [ "pjkind_loc", pjkind_loc; "pjkind_desc", pjkind_desc ]
17651765+17661766+ method function_param_desc : function_param_desc -> 'res =
17671767+ fun x ->
17681768+ match x with
17691769+ | Pparam_val (a, b, c) ->
17701770+ let a = self#arg_label a in
17711771+ let b = self#option self#expression b in
17721772+ let c = self#pattern c in
17731773+ self#constr "Pparam_val" [ a; b; c ]
17741774+ | Pparam_newtype (a, b) ->
17751775+ let a = self#loc self#string a in
17761776+ let b = self#option self#jkind_annotation b in
17771777+ self#constr "Pparam_newtype" [ a; b ]
17781778+17791779+ method function_param : function_param -> 'res =
17801780+ fun { pparam_loc; pparam_desc } ->
17811781+ let pparam_loc = self#location pparam_loc in
17821782+ let pparam_desc = self#function_param_desc pparam_desc in
17831783+ self#record [ "pparam_loc", pparam_loc; "pparam_desc", pparam_desc ]
17841784+17851785+ method type_constraint : type_constraint -> 'res =
17861786+ fun x ->
17871787+ match x with
17881788+ | Pconstraint a ->
17891789+ let a = self#core_type a in
17901790+ self#constr "Pconstraint" [ a ]
17911791+ | Pcoerce (a, b) ->
17921792+ let a = self#option self#core_type a in
17931793+ let b = self#core_type b in
17941794+ self#constr "Pcoerce" [ a; b ]
17951795+17961796+ method function_constraint : function_constraint -> 'res =
17971797+ fun { mode_annotations; ret_mode_annotations; ret_type_constraint } ->
17981798+ let mode_annotations = self#modes mode_annotations in
17991799+ let ret_mode_annotations = self#modes ret_mode_annotations in
18001800+ let ret_type_constraint =
18011801+ self#option self#type_constraint ret_type_constraint
18021802+ in
18031803+ self#record
18041804+ [ "mode_annotations", mode_annotations
18051805+ ; "ret_mode_annotations", ret_mode_annotations
18061806+ ; "ret_type_constraint", ret_type_constraint
18071807+ ]
18081808+18091809+ method function_body : function_body -> 'res =
18101810+ fun x ->
18111811+ match x with
18121812+ | Pfunction_body a ->
18131813+ let a = self#expression a in
18141814+ self#constr "Pfunction_body" [ a ]
18151815+ | Pfunction_cases (a, b, c) ->
18161816+ let a = self#list self#case a in
18171817+ let b = self#location b in
18181818+ let c = self#attributes c in
18191819+ self#constr "Pfunction_cases" [ a; b; c ]
18201820+18211821+ method mode : mode -> 'res =
18221822+ fun x ->
18231823+ match x with
18241824+ | Mode a ->
18251825+ let a = self#string a in
18261826+ self#constr "Mode" [ a ]
18271827+18281828+ method modes : modes -> 'res = self#list (self#loc self#mode)
18291829+18301830+ method modality : modality -> 'res =
18311831+ fun x ->
18321832+ match x with
18331833+ | Modality a ->
18341834+ let a = self#string a in
18351835+ self#constr "Modality" [ a ]
18361836+18371837+ method modalities : modalities -> 'res = self#list (self#loc self#modality)
18381838+ method signature_items : signature_items -> 'res = self#list self#signature_item
18391839+ method signature : signature -> 'res = self#signature_items
18401840+ end
18411841+18421842+ class virtual ['ctx, 'res] lift_map_with_context =
18431843+ object (self)
18441844+ method virtual record : 'ctx -> (string * 'res) list -> 'res
18451845+ method virtual constr : 'ctx -> string -> 'res list -> 'res
18461846+ method virtual arg_label : 'ctx -> arg_label -> arg_label * 'res
18471847+ method virtual attributes : 'ctx -> attributes -> attributes * 'res
18481848+ method virtual case : 'ctx -> case -> case * 'res
18491849+ method virtual core_type : 'ctx -> core_type -> core_type * 'res
18501850+ method virtual expression : 'ctx -> expression -> expression * 'res
18511851+18521852+ method
18531853+ virtual list
18541854+ : 'a. ('ctx -> 'a -> 'a * 'res) -> 'ctx -> 'a list -> 'a list * 'res
18551855+18561856+ method
18571857+ virtual loc
18581858+ : 'a. ('ctx -> 'a -> 'a * 'res) -> 'ctx -> 'a loc -> 'a loc * 'res
18591859+18601860+ method virtual location : 'ctx -> location -> location * 'res
18611861+18621862+ method
18631863+ virtual option
18641864+ : 'a. ('ctx -> 'a -> 'a * 'res) -> 'ctx -> 'a option -> 'a option * 'res
18651865+18661866+ method virtual pattern : 'ctx -> pattern -> pattern * 'res
18671867+ method virtual signature_item : 'ctx -> signature_item -> signature_item * 'res
18681868+ method virtual string : 'ctx -> string -> string * 'res
18691869+18701870+ method jkind_annotation_desc
18711871+ : 'ctx -> jkind_annotation_desc -> jkind_annotation_desc * 'res =
18721872+ fun ctx x ->
18731873+ match x with
18741874+ | Pjk_default -> Pjk_default, self#constr ctx "Pjk_default" []
18751875+ | Pjk_abbreviation a ->
18761876+ let a = self#string ctx a in
18771877+ ( Pjk_abbreviation (Stdlib.fst a)
18781878+ , self#constr ctx "Pjk_abbreviation" [ Stdlib.snd a ] )
18791879+ | Pjk_mod (a, b) ->
18801880+ let a = self#jkind_annotation ctx a in
18811881+ let b = self#modes ctx b in
18821882+ ( Pjk_mod (Stdlib.fst a, Stdlib.fst b)
18831883+ , self#constr ctx "Pjk_mod" [ Stdlib.snd a; Stdlib.snd b ] )
18841884+ | Pjk_with (a, b, c) ->
18851885+ let a = self#jkind_annotation ctx a in
18861886+ let b = self#core_type ctx b in
18871887+ let c = self#modalities ctx c in
18881888+ ( Pjk_with (Stdlib.fst a, Stdlib.fst b, Stdlib.fst c)
18891889+ , self#constr ctx "Pjk_with" [ Stdlib.snd a; Stdlib.snd b; Stdlib.snd c ] )
18901890+ | Pjk_kind_of a ->
18911891+ let a = self#core_type ctx a in
18921892+ Pjk_kind_of (Stdlib.fst a), self#constr ctx "Pjk_kind_of" [ Stdlib.snd a ]
18931893+ | Pjk_product a ->
18941894+ let a = self#list self#jkind_annotation ctx a in
18951895+ Pjk_product (Stdlib.fst a), self#constr ctx "Pjk_product" [ Stdlib.snd a ]
18961896+18971897+ method jkind_annotation : 'ctx -> jkind_annotation -> jkind_annotation * 'res =
18981898+ fun ctx { pjkind_loc; pjkind_desc } ->
18991899+ let pjkind_loc = self#location ctx pjkind_loc in
19001900+ let pjkind_desc = self#jkind_annotation_desc ctx pjkind_desc in
19011901+ ( { pjkind_loc = Stdlib.fst pjkind_loc; pjkind_desc = Stdlib.fst pjkind_desc }
19021902+ , self#record
19031903+ ctx
19041904+ [ "pjkind_loc", Stdlib.snd pjkind_loc
19051905+ ; "pjkind_desc", Stdlib.snd pjkind_desc
19061906+ ] )
19071907+19081908+ method function_param_desc
19091909+ : 'ctx -> function_param_desc -> function_param_desc * 'res =
19101910+ fun ctx x ->
19111911+ match x with
19121912+ | Pparam_val (a, b, c) ->
19131913+ let a = self#arg_label ctx a in
19141914+ let b = self#option self#expression ctx b in
19151915+ let c = self#pattern ctx c in
19161916+ ( Pparam_val (Stdlib.fst a, Stdlib.fst b, Stdlib.fst c)
19171917+ , self#constr ctx "Pparam_val" [ Stdlib.snd a; Stdlib.snd b; Stdlib.snd c ]
19181918+ )
19191919+ | Pparam_newtype (a, b) ->
19201920+ let a = self#loc self#string ctx a in
19211921+ let b = self#option self#jkind_annotation ctx b in
19221922+ ( Pparam_newtype (Stdlib.fst a, Stdlib.fst b)
19231923+ , self#constr ctx "Pparam_newtype" [ Stdlib.snd a; Stdlib.snd b ] )
19241924+19251925+ method function_param : 'ctx -> function_param -> function_param * 'res =
19261926+ fun ctx { pparam_loc; pparam_desc } ->
19271927+ let pparam_loc = self#location ctx pparam_loc in
19281928+ let pparam_desc = self#function_param_desc ctx pparam_desc in
19291929+ ( { pparam_loc = Stdlib.fst pparam_loc; pparam_desc = Stdlib.fst pparam_desc }
19301930+ , self#record
19311931+ ctx
19321932+ [ "pparam_loc", Stdlib.snd pparam_loc
19331933+ ; "pparam_desc", Stdlib.snd pparam_desc
19341934+ ] )
19351935+19361936+ method type_constraint : 'ctx -> type_constraint -> type_constraint * 'res =
19371937+ fun ctx x ->
19381938+ match x with
19391939+ | Pconstraint a ->
19401940+ let a = self#core_type ctx a in
19411941+ Pconstraint (Stdlib.fst a), self#constr ctx "Pconstraint" [ Stdlib.snd a ]
19421942+ | Pcoerce (a, b) ->
19431943+ let a = self#option self#core_type ctx a in
19441944+ let b = self#core_type ctx b in
19451945+ ( Pcoerce (Stdlib.fst a, Stdlib.fst b)
19461946+ , self#constr ctx "Pcoerce" [ Stdlib.snd a; Stdlib.snd b ] )
19471947+19481948+ method function_constraint
19491949+ : 'ctx -> function_constraint -> function_constraint * 'res =
19501950+ fun ctx { mode_annotations; ret_mode_annotations; ret_type_constraint } ->
19511951+ let mode_annotations = self#modes ctx mode_annotations in
19521952+ let ret_mode_annotations = self#modes ctx ret_mode_annotations in
19531953+ let ret_type_constraint =
19541954+ self#option self#type_constraint ctx ret_type_constraint
19551955+ in
19561956+ ( { mode_annotations = Stdlib.fst mode_annotations
19571957+ ; ret_mode_annotations = Stdlib.fst ret_mode_annotations
19581958+ ; ret_type_constraint = Stdlib.fst ret_type_constraint
19591959+ }
19601960+ , self#record
19611961+ ctx
19621962+ [ "mode_annotations", Stdlib.snd mode_annotations
19631963+ ; "ret_mode_annotations", Stdlib.snd ret_mode_annotations
19641964+ ; "ret_type_constraint", Stdlib.snd ret_type_constraint
19651965+ ] )
19661966+19671967+ method function_body : 'ctx -> function_body -> function_body * 'res =
19681968+ fun ctx x ->
19691969+ match x with
19701970+ | Pfunction_body a ->
19711971+ let a = self#expression ctx a in
19721972+ ( Pfunction_body (Stdlib.fst a)
19731973+ , self#constr ctx "Pfunction_body" [ Stdlib.snd a ] )
19741974+ | Pfunction_cases (a, b, c) ->
19751975+ let a = self#list self#case ctx a in
19761976+ let b = self#location ctx b in
19771977+ let c = self#attributes ctx c in
19781978+ ( Pfunction_cases (Stdlib.fst a, Stdlib.fst b, Stdlib.fst c)
19791979+ , self#constr
19801980+ ctx
19811981+ "Pfunction_cases"
19821982+ [ Stdlib.snd a; Stdlib.snd b; Stdlib.snd c ] )
19831983+19841984+ method mode : 'ctx -> mode -> mode * 'res =
19851985+ fun ctx x ->
19861986+ match x with
19871987+ | Mode a ->
19881988+ let a = self#string ctx a in
19891989+ Mode (Stdlib.fst a), self#constr ctx "Mode" [ Stdlib.snd a ]
19901990+19911991+ method modes : 'ctx -> modes -> modes * 'res = self#list (self#loc self#mode)
19921992+19931993+ method modality : 'ctx -> modality -> modality * 'res =
19941994+ fun ctx x ->
19951995+ match x with
19961996+ | Modality a ->
19971997+ let a = self#string ctx a in
19981998+ Modality (Stdlib.fst a), self#constr ctx "Modality" [ Stdlib.snd a ]
19991999+20002000+ method modalities : 'ctx -> modalities -> modalities * 'res =
20012001+ self#list (self#loc self#modality)
20022002+20032003+ method signature_items : 'ctx -> signature_items -> signature_items * 'res =
20042004+ self#list self#signature_item
20052005+20062006+ method signature : 'ctx -> signature -> signature * 'res = self#signature_items
20072007+ end
20082008+20092009+ [@@@end]
20102010+ end
20112011+20122012+ module Jane_street_extensions0 (T : sig
20132013+ type 'a t
20142014+ end) =
20152015+ struct
20162016+ class type t = object
20172017+ method jkind_annotation : jkind_annotation T.t
20182018+ method jkind_annotation_desc : jkind_annotation_desc T.t
20192019+ method function_body : Pexp_function.function_body T.t
20202020+ method function_param : Pexp_function.function_param T.t
20212021+ method function_param_desc : Pexp_function.function_param_desc T.t
20222022+ method function_constraint : Pexp_function.Function_constraint.t T.t
20232023+ method type_constraint : Pexp_function.type_constraint T.t
20242024+ method mode : Mode.t T.t
20252025+ method modes : Modes.t T.t
20262026+ method modality : Modality.t T.t
20272027+ method modalities : Modalities.t T.t
20282028+ method signature_items : signature_item list T.t
20292029+ end
20302030+ end
20312031+20322032+ module Jane_street_extensions0_ctx (T : sig
20332033+ type ('a, 'b) t
20342034+ end) =
20352035+ struct
20362036+ class type ['ctx] t = object
20372037+ method jkind_annotation : ('ctx, jkind_annotation) T.t
20382038+ method jkind_annotation_desc : ('ctx, jkind_annotation_desc) T.t
20392039+ method function_body : ('ctx, Pexp_function.function_body) T.t
20402040+ method function_param : ('ctx, Pexp_function.function_param) T.t
20412041+ method function_param_desc : ('ctx, Pexp_function.function_param_desc) T.t
20422042+ method function_constraint : ('ctx, Pexp_function.Function_constraint.t) T.t
20432043+ method type_constraint : ('ctx, Pexp_function.type_constraint) T.t
20442044+ method mode : ('ctx, Mode.t) T.t
20452045+ method modes : ('ctx, Modes.t) T.t
20462046+ method modality : ('ctx, Modality.t) T.t
20472047+ method modalities : ('ctx, Modalities.t) T.t
20482048+ method signature_items : ('ctx, signature_item list) T.t
20492049+ end
20502050+ end
20512051+20522052+ module Jane_street_extensions1 (T : sig
20532053+ type ('a, 'b) t
20542054+ end) =
20552055+ struct
20562056+ class type ['a] t = object
20572057+ method jkind_annotation : (jkind_annotation, 'a) T.t
20582058+ method jkind_annotation_desc : (jkind_annotation_desc, 'a) T.t
20592059+ method function_body : (Pexp_function.function_body, 'a) T.t
20602060+ method function_param : (Pexp_function.function_param, 'a) T.t
20612061+ method function_param_desc : (Pexp_function.function_param_desc, 'a) T.t
20622062+ method function_constraint : (Pexp_function.Function_constraint.t, 'a) T.t
20632063+ method type_constraint : (Pexp_function.type_constraint, 'a) T.t
20642064+ method mode : (Mode.t, 'a) T.t
20652065+ method modes : (Modes.t, 'a) T.t
20662066+ method modality : (Modality.t, 'a) T.t
20672067+ method modalities : (Modalities.t, 'a) T.t
20682068+ method signature_items : (signature_item list, 'a) T.t
20692069+ end
20702070+ end
20712071+20722072+ module Jane_street_extensions1_ctx (T : sig
20732073+ type ('a, 'b, 'c) t
20742074+ end) =
20752075+ struct
20762076+ class type ['ctx, 'res] t = object
20772077+ method jkind_annotation : ('ctx, jkind_annotation, 'res) T.t
20782078+ method jkind_annotation_desc : ('ctx, jkind_annotation_desc, 'res) T.t
20792079+ method function_body : ('ctx, Pexp_function.function_body, 'res) T.t
20802080+ method function_param : ('ctx, Pexp_function.function_param, 'res) T.t
20812081+ method function_param_desc : ('ctx, Pexp_function.function_param_desc, 'res) T.t
20822082+ method function_constraint : ('ctx, Pexp_function.Function_constraint.t, 'res) T.t
20832083+ method type_constraint : ('ctx, Pexp_function.type_constraint, 'res) T.t
20842084+ method mode : ('ctx, Mode.t, 'res) T.t
20852085+ method modes : ('ctx, Modes.t, 'res) T.t
20862086+ method modality : ('ctx, Modality.t, 'res) T.t
20872087+ method modalities : ('ctx, Modalities.t, 'res) T.t
20882088+ method signature_items : ('ctx, signature_item list, 'res) T.t
20892089+ end
20902090+ end
20912091+20922092+ module Ts = struct
20932093+ module Map = struct
20942094+ type 'a t = 'a Ppxlib_traverse_builtins.T.map
20952095+ end
20962096+20972097+ module Iter = struct
20982098+ type 'a t = 'a Ppxlib_traverse_builtins.T.iter
20992099+ end
21002100+21012101+ module Fold = struct
21022102+ type ('a, 'b) t = ('b, 'a) Ppxlib_traverse_builtins.T.fold
21032103+ end
21042104+21052105+ module Fold_map = struct
21062106+ type ('a, 'b) t = ('b, 'a) Ppxlib_traverse_builtins.T.fold_map
21072107+ end
21082108+21092109+ module Map_with_context = struct
21102110+ type ('a, 'b) t = ('a, 'b) Ppxlib_traverse_builtins.T.map_with_context
21112111+ end
21122112+21132113+ module Lift = struct
21142114+ type ('a, 'b) t = ('a, 'b) Ppxlib_traverse_builtins.T.lift
21152115+ end
21162116+21172117+ module Lift_map_with_context = struct
21182118+ type ('a, 'b, 'c) t = ('a, 'b, 'c) Ppxlib_traverse_builtins.T.lift_map_with_context
21192119+ end
21202120+ end
21212121+21222122+ class virtual map =
21232123+ object
21242124+ inherit Ppxlib_ast.Ast.map
21252125+ inherit Deriving_inline.map
21262126+ end
21272127+21282128+ class virtual iter =
21292129+ object
21302130+ inherit Ppxlib_ast.Ast.iter
21312131+ inherit Deriving_inline.iter
21322132+ end
21332133+21342134+ class virtual ['ctx] fold =
21352135+ object
21362136+ inherit ['ctx] Ppxlib_ast.Ast.fold
21372137+ inherit ['ctx] Deriving_inline.fold
21382138+ end
21392139+21402140+ class virtual ['ctx] fold_map =
21412141+ object
21422142+ inherit ['ctx] Ppxlib_ast.Ast.fold_map
21432143+ inherit ['ctx] Deriving_inline.fold_map
21442144+ end
21452145+21462146+ class virtual ['ctx] map_with_context =
21472147+ object
21482148+ inherit ['ctx] Ppxlib_ast.Ast.map_with_context
21492149+ inherit ['ctx] Deriving_inline.map_with_context
21502150+ end
21512151+21522152+ class virtual ['res] lift =
21532153+ object
21542154+ inherit ['res] Ppxlib_ast.Ast.lift
21552155+ inherit ['res] Deriving_inline.lift
21562156+ end
21572157+21582158+ class virtual ['ctx, 'res] lift_map_with_context =
21592159+ object
21602160+ inherit ['ctx, 'res] Ppxlib_ast.Ast.lift_map_with_context
21612161+ inherit ['ctx, 'res] Deriving_inline.lift_map_with_context
21622162+ end
21632163+end
+628
vendor/opam/ppxlib_jane/src/shim.mli
···11+open Astlib
22+open Ppxlib_ast.Asttypes
33+open Ppxlib_ast.Parsetree
44+55+(** This file can have a different implementation in the Jane Street experimental compiler
66+ and the upstream compiler, allowing ppxes to easily work with both versions *)
77+88+module Mode : sig
99+ (** The modes that can go on function arguments or return types *)
1010+ type t = Mode of string [@@unboxed]
1111+end
1212+1313+module Modes : sig
1414+ type t = Mode.t loc list
1515+1616+ val none : t
1717+ val local : loc:Location.t -> t
1818+end
1919+2020+module Modality : sig
2121+ (** The modalities that can go on constructor fields *)
2222+ type t = Modality of string [@@unboxed]
2323+end
2424+2525+module Modalities : sig
2626+ type t = Modality.t loc list
2727+2828+ val none : t
2929+ val portable : loc:Location.t -> t
3030+end
3131+3232+module Include_kind : sig
3333+ type t =
3434+ | Structure
3535+ | Functor
3636+end
3737+3838+(** Function arguments; a value of this type represents:
3939+ - [arg_mode arg_type -> ...] when [arg_label] is {{!Asttypes.arg_label.Nolabel}
4040+ [Nolabel]},
4141+ - [l:arg_mode arg_type -> ...] when [arg_label] is {{!Asttypes.arg_label.Labelled}
4242+ [Labelled]}, and
4343+ - [?l:arg_mode arg_type -> ...] when [arg_label] is {{!Asttypes.arg_label.Optional}
4444+ [Optional]}. *)
4545+type arrow_argument =
4646+ { arg_label : arg_label
4747+ ; arg_modes : Modes.t
4848+ ; arg_type : core_type
4949+ }
5050+5151+(** Function return types; a value of this type represents
5252+ [... -> result_mode result_type]. *)
5353+type arrow_result =
5454+ { result_modes : Modes.t
5555+ ; result_type : core_type
5656+ }
5757+5858+(** A list of this type is stored in the [Pcstr_tuple] constructor of
5959+ [constructor_arguments]. With JS extensions, fields in constructors can contain
6060+ modalities. *)
6161+module Pcstr_tuple_arg : sig
6262+ type t = core_type
6363+6464+ val extract_modalities : t -> Modalities.t * core_type
6565+ val to_core_type : t -> core_type
6666+ val of_core_type : core_type -> t
6767+ val map_core_type : t -> f:(core_type -> core_type) -> t
6868+ val map_core_type_extra : t -> f:(core_type -> core_type * 'a) -> t * 'a
6969+7070+ (** [loc] is ignored if there is no modality. *)
7171+ val create : loc:Location.t -> modalities:Modalities.t -> type_:core_type -> t
7272+end
7373+7474+(** This is an interface around the [Parsetree.label_declaration] type, describing one
7575+ label in a record declaration. *)
7676+module Label_declaration : sig
7777+ val extract_modalities : label_declaration -> Modalities.t * label_declaration
7878+7979+ val create
8080+ : loc:Location.t
8181+ -> name:string Location.loc
8282+ -> mutable_:mutable_flag
8383+ -> modalities:Modalities.t
8484+ -> type_:core_type
8585+ -> label_declaration
8686+end
8787+8888+module Value_description : sig
8989+ val extract_modalities : value_description -> Modalities.t * value_description
9090+9191+ val create
9292+ : loc:Location.t
9393+ -> name:string Location.loc
9494+ -> type_:core_type
9595+ -> modalities:Modalities.t
9696+ -> prim:string list
9797+ -> value_description
9898+end
9999+100100+module Module_declaration : sig
101101+ type t =
102102+ { pmd_name : string option loc
103103+ ; pmd_type : module_type
104104+ ; pmd_modalities : Modalities.t
105105+ ; pmd_attributes : attributes (** [... [\@\@id1] [\@\@id2]] *)
106106+ ; pmd_loc : Location.t
107107+ }
108108+109109+ val to_parsetree : t -> module_declaration
110110+ val of_parsetree : module_declaration -> t
111111+end
112112+113113+module Value_binding : sig
114114+ val extract_modes : value_binding -> Modes.t * value_binding
115115+116116+ val create
117117+ : loc:Location.t
118118+ -> pat:pattern
119119+ -> expr:expression
120120+ -> modes:Modes.t
121121+ -> value_binding
122122+end
123123+124124+type jkind_annotation_desc =
125125+ | Pjk_default
126126+ | Pjk_abbreviation of string
127127+ | Pjk_mod of jkind_annotation * Modes.t
128128+ | Pjk_with of jkind_annotation * core_type * Modalities.t
129129+ | Pjk_kind_of of core_type
130130+ | Pjk_product of jkind_annotation list
131131+132132+and jkind_annotation =
133133+ { pjkind_loc : Location.t
134134+ ; pjkind_desc : jkind_annotation_desc
135135+ }
136136+137137+module Type_declaration : sig
138138+ type t =
139139+ { ptype_name : string loc
140140+ ; ptype_params : (core_type * (variance * injectivity)) list
141141+ ; ptype_cstrs : (core_type * core_type * Location.t) list
142142+ ; ptype_kind : type_kind
143143+ ; ptype_private : private_flag
144144+ ; ptype_manifest : core_type option
145145+ ; ptype_attributes : attributes
146146+ ; ptype_jkind_annotation : jkind_annotation option
147147+ ; ptype_loc : Location.t
148148+ }
149149+150150+ val of_parsetree : type_declaration -> t
151151+ val to_parsetree : t -> type_declaration
152152+ val extract_jkind_annotation : type_declaration -> jkind_annotation option
153153+end
154154+155155+module Constant : sig
156156+ type t =
157157+ | Pconst_integer of string * char option
158158+ | Pconst_unboxed_integer of string * char
159159+ | Pconst_char of char
160160+ | Pconst_untagged_char of char
161161+ | Pconst_string of string * Location.t * string option
162162+ | Pconst_float of string * char option
163163+ | Pconst_unboxed_float of string * char option
164164+165165+ val of_parsetree : constant -> t
166166+ val to_parsetree : t -> constant
167167+end
168168+169169+(** Match and construct [Pexp_function], as in the OCaml parsetree at or after 5.2. *)
170170+module Pexp_function : sig
171171+ type function_param_desc =
172172+ | Pparam_val of arg_label * expression option * pattern
173173+ | Pparam_newtype of string loc * jkind_annotation option
174174+175175+ type function_param =
176176+ { pparam_loc : Location.t
177177+ ; pparam_desc : function_param_desc
178178+ }
179179+180180+ type type_constraint =
181181+ | Pconstraint of core_type
182182+ | Pcoerce of core_type option * core_type
183183+184184+ module Function_constraint : sig
185185+ type t =
186186+ { mode_annotations : Modes.t
187187+ ; ret_mode_annotations : Modes.t
188188+ ; ret_type_constraint : type_constraint option
189189+ }
190190+191191+ val none : t
192192+ val is_none : t -> bool
193193+ end
194194+195195+ type function_body =
196196+ | Pfunction_body of expression
197197+ | Pfunction_cases of case list * Location.t * attributes
198198+199199+ val to_parsetree
200200+ : params:function_param list
201201+ -> constraint_:Function_constraint.t
202202+ -> body:function_body
203203+ -> expression_desc
204204+205205+ val of_parsetree
206206+ : expression_desc
207207+ -> loc:Location.t
208208+ -> (function_param list * Function_constraint.t * function_body) option
209209+end
210210+211211+type index_kind =
212212+ | Index_int
213213+ | Index_unboxed_int64
214214+ | Index_unboxed_int32
215215+ | Index_unboxed_int16
216216+ | Index_unboxed_int8
217217+ | Index_unboxed_nativeint
218218+219219+type block_access =
220220+ | Baccess_field of Longident.t loc
221221+ | Baccess_array of mutable_flag * index_kind * expression
222222+ | Baccess_block of mutable_flag * expression
223223+224224+type unboxed_access = Uaccess_unboxed_field of Longident.t loc
225225+226226+module Core_type_desc : sig
227227+ type t =
228228+ | Ptyp_any of jkind_annotation option
229229+ | Ptyp_var of string * jkind_annotation option
230230+ | Ptyp_arrow of arg_label * core_type * core_type * Modes.t * Modes.t
231231+ | Ptyp_tuple of (string option * core_type) list
232232+ | Ptyp_unboxed_tuple of (string option * core_type) list
233233+ | Ptyp_constr of Longident.t loc * core_type list
234234+ | Ptyp_object of object_field list * closed_flag
235235+ | Ptyp_class of Longident.t loc * core_type list
236236+ | Ptyp_alias of core_type * string loc option * jkind_annotation option
237237+ | Ptyp_variant of row_field list * closed_flag * label list option
238238+ | Ptyp_poly of (string loc * jkind_annotation option) list * core_type
239239+ | Ptyp_package of package_type
240240+ | Ptyp_quote of core_type
241241+ | Ptyp_splice of core_type
242242+ | Ptyp_of_kind of jkind_annotation
243243+ | Ptyp_extension of extension
244244+245245+ val of_parsetree : core_type_desc -> t
246246+ val to_parsetree : t -> core_type_desc
247247+end
248248+249249+module Core_type : sig
250250+ type t =
251251+ { ptyp_desc : Core_type_desc.t
252252+ ; ptyp_loc : Location.t
253253+ ; ptyp_loc_stack : Location.t list
254254+ ; ptyp_attributes : attributes
255255+ }
256256+257257+ val of_parsetree : core_type -> t
258258+ val to_parsetree : t -> core_type
259259+end
260260+261261+module Pattern_desc : sig
262262+ type t =
263263+ | Ppat_any
264264+ | Ppat_var of string loc
265265+ | Ppat_alias of pattern * string loc
266266+ | Ppat_constant of constant
267267+ | Ppat_interval of constant * constant
268268+ | Ppat_tuple of (string option * pattern) list * closed_flag
269269+ | Ppat_unboxed_tuple of (string option * pattern) list * closed_flag
270270+ | Ppat_construct of
271271+ Longident.t loc * ((string loc * jkind_annotation option) list * pattern) option
272272+ | Ppat_variant of label * pattern option
273273+ | Ppat_record of (Longident.t loc * pattern) list * closed_flag
274274+ | Ppat_record_unboxed_product of (Longident.t loc * pattern) list * closed_flag
275275+ | Ppat_array of mutable_flag * pattern list
276276+ | Ppat_or of pattern * pattern
277277+ | Ppat_constraint of pattern * core_type option * Modes.t
278278+ | Ppat_type of Longident.t loc
279279+ | Ppat_lazy of pattern
280280+ | Ppat_unpack of string option loc
281281+ | Ppat_exception of pattern
282282+ | Ppat_extension of extension
283283+ | Ppat_open of Longident.t loc * pattern
284284+285285+ val of_parsetree : pattern_desc -> t
286286+ val to_parsetree : loc:Location.t -> t -> pattern_desc
287287+end
288288+289289+module Expression_desc : sig
290290+ type comprehension_expression = private
291291+ | Pcomp_list_comprehension of unit
292292+ | Pcomp_array_comprehension of unit
293293+294294+ type t =
295295+ | Pexp_ident of Longident.t loc
296296+ | Pexp_constant of constant
297297+ | Pexp_let of mutable_flag * rec_flag * value_binding list * expression
298298+ | Pexp_function of
299299+ Pexp_function.function_param list
300300+ * Pexp_function.Function_constraint.t
301301+ * Pexp_function.function_body
302302+ | Pexp_apply of expression * (arg_label * expression) list
303303+ | Pexp_match of expression * case list
304304+ | Pexp_try of expression * case list
305305+ | Pexp_tuple of (string option * expression) list
306306+ | Pexp_unboxed_tuple of (string option * expression) list
307307+ | Pexp_construct of Longident.t loc * expression option
308308+ | Pexp_variant of label * expression option
309309+ | Pexp_record of (Longident.t loc * expression) list * expression option
310310+ | Pexp_record_unboxed_product of
311311+ (Longident.t loc * expression) list * expression option
312312+ | Pexp_field of expression * Longident.t loc
313313+ | Pexp_unboxed_field of expression * Longident.t loc
314314+ | Pexp_setfield of expression * Longident.t loc * expression
315315+ | Pexp_array of mutable_flag * expression list
316316+ | Pexp_idx of block_access * unboxed_access list
317317+ | Pexp_ifthenelse of expression * expression * expression option
318318+ | Pexp_sequence of expression * expression
319319+ | Pexp_while of expression * expression
320320+ | Pexp_for of pattern * expression * expression * direction_flag * expression
321321+ | Pexp_constraint of expression * core_type option * Modes.t
322322+ | Pexp_coerce of expression * core_type option * core_type
323323+ | Pexp_send of expression * label loc
324324+ | Pexp_new of Longident.t loc
325325+ | Pexp_setvar of label loc * expression
326326+ | Pexp_override of (label loc * expression) list
327327+ | Pexp_letmodule of string option loc * module_expr * expression
328328+ | Pexp_letexception of extension_constructor * expression
329329+ | Pexp_assert of expression
330330+ | Pexp_lazy of expression
331331+ | Pexp_poly of expression * core_type option
332332+ | Pexp_object of class_structure
333333+ | Pexp_newtype of string loc * jkind_annotation option * expression
334334+ | Pexp_pack of module_expr
335335+ | Pexp_open of open_declaration * expression
336336+ | Pexp_letop of letop
337337+ | Pexp_extension of extension
338338+ | Pexp_unreachable
339339+ | Pexp_stack of expression
340340+ | Pexp_comprehension of comprehension_expression
341341+ | Pexp_overwrite of expression * expression
342342+ | Pexp_quote of expression
343343+ | Pexp_splice of expression
344344+ | Pexp_hole
345345+346346+ val of_parsetree : expression_desc -> loc:Location.t -> t
347347+ val to_parsetree : loc:Location.t -> t -> expression_desc
348348+end
349349+350350+module Type_kind : sig
351351+ type t =
352352+ | Ptype_abstract
353353+ | Ptype_variant of constructor_declaration list
354354+ | Ptype_record of label_declaration list
355355+ | Ptype_record_unboxed_product of label_declaration list
356356+ | Ptype_open
357357+358358+ val of_parsetree : type_kind -> t
359359+ val to_parsetree : t -> type_kind
360360+end
361361+362362+module Constructor_declaration : sig
363363+ val extract_vars_with_jkind_annotations
364364+ : constructor_declaration
365365+ -> (string loc * jkind_annotation option) list
366366+367367+ val create
368368+ : name:string loc
369369+ -> vars:(string loc * jkind_annotation option) list
370370+ -> args:constructor_arguments
371371+ -> res:core_type option
372372+ -> loc:Location.t
373373+ -> constructor_declaration
374374+end
375375+376376+module Include_infos : sig
377377+ type 'a t =
378378+ { pincl_kind : Include_kind.t
379379+ ; pincl_mod : 'a
380380+ ; pincl_loc : Location.t
381381+ ; pincl_attributes : attributes
382382+ }
383383+384384+ val of_parsetree : 'a include_infos -> 'a t
385385+ val to_parsetree : 'a t -> 'a include_infos
386386+end
387387+388388+module Signature_item_desc : sig
389389+ type t =
390390+ | Psig_value of value_description
391391+ | Psig_type of rec_flag * type_declaration list
392392+ | Psig_typesubst of type_declaration list
393393+ | Psig_typext of type_extension
394394+ | Psig_exception of type_exception
395395+ | Psig_module of module_declaration
396396+ | Psig_modsubst of module_substitution
397397+ | Psig_recmodule of module_declaration list
398398+ | Psig_modtype of module_type_declaration
399399+ | Psig_modtypesubst of module_type_declaration
400400+ | Psig_open of open_description
401401+ | Psig_include of include_description * Modalities.t
402402+ | Psig_class of class_description list
403403+ | Psig_class_type of class_type_declaration list
404404+ | Psig_attribute of attribute
405405+ | Psig_extension of extension * attributes
406406+ | Psig_kind_abbrev of string loc * jkind_annotation
407407+408408+ val of_parsetree : signature_item_desc -> t
409409+ val to_parsetree : t -> signature_item_desc
410410+end
411411+412412+module Signature : sig
413413+ type t =
414414+ { psg_modalities : Modalities.t
415415+ ; psg_items : signature_item list
416416+ ; psg_loc : Location.t
417417+ }
418418+419419+ val of_parsetree : signature -> t
420420+ val to_parsetree : t -> signature
421421+end
422422+423423+module Structure_item_desc : sig
424424+ type t =
425425+ | Pstr_eval of expression * attributes
426426+ | Pstr_value of rec_flag * value_binding list
427427+ | Pstr_primitive of value_description
428428+ | Pstr_type of rec_flag * type_declaration list
429429+ | Pstr_typext of type_extension
430430+ | Pstr_exception of type_exception
431431+ | Pstr_module of module_binding
432432+ | Pstr_recmodule of module_binding list
433433+ | Pstr_modtype of module_type_declaration
434434+ | Pstr_open of open_declaration
435435+ | Pstr_class of class_declaration list
436436+ | Pstr_class_type of class_type_declaration list
437437+ | Pstr_include of include_declaration
438438+ | Pstr_attribute of attribute
439439+ | Pstr_extension of extension * attributes
440440+ | Pstr_kind_abbrev of string loc * jkind_annotation
441441+442442+ val of_parsetree : structure_item_desc -> t
443443+ val to_parsetree : t -> structure_item_desc
444444+end
445445+446446+module Functor_parameter : sig
447447+ type t =
448448+ | Unit
449449+ | Named of string option loc * module_type * Modes.t
450450+451451+ val to_parsetree : t -> functor_parameter
452452+ val of_parsetree : functor_parameter -> t
453453+end
454454+455455+module Module_type_desc : sig
456456+ type t =
457457+ | Pmty_ident of Longident.t loc
458458+ | Pmty_signature of signature
459459+ | Pmty_functor of functor_parameter * module_type * Modes.t
460460+ | Pmty_with of module_type * with_constraint list
461461+ | Pmty_typeof of module_expr
462462+ | Pmty_extension of extension
463463+ | Pmty_alias of Longident.t loc
464464+ | Pmty_strengthen of module_type * Longident.t loc
465465+466466+ val of_parsetree : module_type_desc -> t
467467+ val to_parsetree : loc:Location.t -> t -> module_type_desc
468468+end
469469+470470+module Module_expr_desc : sig
471471+ type module_instance = private Module_instance
472472+473473+ type t =
474474+ | Pmod_ident of Longident.t loc
475475+ | Pmod_structure of structure
476476+ | Pmod_functor of functor_parameter * module_expr
477477+ | Pmod_apply of module_expr * module_expr
478478+ | Pmod_constraint of module_expr * module_type option * Modes.t
479479+ | Pmod_unpack of expression
480480+ | Pmod_extension of extension
481481+ | Pmod_instance of module_instance
482482+483483+ val of_parsetree : module_expr_desc -> t
484484+ val to_parsetree : loc:Location.t -> t -> module_expr_desc
485485+end
486486+487487+module Ast_traverse : sig
488488+ module Jane_street_extensions0 (T : sig
489489+ type 'a t
490490+ end) : sig
491491+ class type t = object
492492+ method jkind_annotation : jkind_annotation T.t
493493+ method jkind_annotation_desc : jkind_annotation_desc T.t
494494+ method function_body : Pexp_function.function_body T.t
495495+ method function_param : Pexp_function.function_param T.t
496496+ method function_param_desc : Pexp_function.function_param_desc T.t
497497+ method function_constraint : Pexp_function.Function_constraint.t T.t
498498+ method type_constraint : Pexp_function.type_constraint T.t
499499+ method mode : Mode.t T.t
500500+ method modes : Modes.t T.t
501501+ method modality : Modality.t T.t
502502+ method modalities : Modalities.t T.t
503503+ method signature_items : signature_item list T.t
504504+ end
505505+ end
506506+507507+ module Jane_street_extensions0_ctx (T : sig
508508+ type ('a, 'b) t
509509+ end) : sig
510510+ class type ['ctx] t = object
511511+ method jkind_annotation : ('ctx, jkind_annotation) T.t
512512+ method jkind_annotation_desc : ('ctx, jkind_annotation_desc) T.t
513513+ method function_body : ('ctx, Pexp_function.function_body) T.t
514514+ method function_param : ('ctx, Pexp_function.function_param) T.t
515515+ method function_param_desc : ('ctx, Pexp_function.function_param_desc) T.t
516516+ method function_constraint : ('ctx, Pexp_function.Function_constraint.t) T.t
517517+ method type_constraint : ('ctx, Pexp_function.type_constraint) T.t
518518+ method mode : ('ctx, Mode.t) T.t
519519+ method modes : ('ctx, Modes.t) T.t
520520+ method modality : ('ctx, Modality.t) T.t
521521+ method modalities : ('ctx, Modalities.t) T.t
522522+ method signature_items : ('ctx, signature_item list) T.t
523523+ end
524524+ end
525525+526526+ module Jane_street_extensions1 (T : sig
527527+ type ('a, 'b) t
528528+ end) : sig
529529+ class type ['a] t = object
530530+ method jkind_annotation : (jkind_annotation, 'a) T.t
531531+ method jkind_annotation_desc : (jkind_annotation_desc, 'a) T.t
532532+ method function_body : (Pexp_function.function_body, 'a) T.t
533533+ method function_param : (Pexp_function.function_param, 'a) T.t
534534+ method function_param_desc : (Pexp_function.function_param_desc, 'a) T.t
535535+ method function_constraint : (Pexp_function.Function_constraint.t, 'a) T.t
536536+ method type_constraint : (Pexp_function.type_constraint, 'a) T.t
537537+ method mode : (Mode.t, 'a) T.t
538538+ method modes : (Modes.t, 'a) T.t
539539+ method modality : (Modality.t, 'a) T.t
540540+ method modalities : (Modalities.t, 'a) T.t
541541+ method signature_items : (signature_item list, 'a) T.t
542542+ end
543543+ end
544544+545545+ module Jane_street_extensions1_ctx (T : sig
546546+ type ('a, 'b, 'c) t
547547+ end) : sig
548548+ class type ['ctx, 'res] t = object
549549+ method jkind_annotation : ('ctx, jkind_annotation, 'res) T.t
550550+ method jkind_annotation_desc : ('ctx, jkind_annotation_desc, 'res) T.t
551551+ method function_body : ('ctx, Pexp_function.function_body, 'res) T.t
552552+ method function_param : ('ctx, Pexp_function.function_param, 'res) T.t
553553+ method function_param_desc : ('ctx, Pexp_function.function_param_desc, 'res) T.t
554554+ method function_constraint : ('ctx, Pexp_function.Function_constraint.t, 'res) T.t
555555+ method type_constraint : ('ctx, Pexp_function.type_constraint, 'res) T.t
556556+ method mode : ('ctx, Mode.t, 'res) T.t
557557+ method modes : ('ctx, Modes.t, 'res) T.t
558558+ method modality : ('ctx, Modality.t, 'res) T.t
559559+ method modalities : ('ctx, Modalities.t, 'res) T.t
560560+ method signature_items : ('ctx, signature_item list, 'res) T.t
561561+ end
562562+ end
563563+564564+ module Ts : sig
565565+ module Map : sig
566566+ type 'a t = 'a Ppxlib_traverse_builtins.T.map
567567+ end
568568+569569+ module Iter : sig
570570+ type 'a t = 'a Ppxlib_traverse_builtins.T.iter
571571+ end
572572+573573+ module Fold : sig
574574+ type ('a, 'b) t = ('b, 'a) Ppxlib_traverse_builtins.T.fold
575575+ end
576576+577577+ module Fold_map : sig
578578+ type ('a, 'b) t = ('b, 'a) Ppxlib_traverse_builtins.T.fold_map
579579+ end
580580+581581+ module Map_with_context : sig
582582+ type ('a, 'b) t = ('a, 'b) Ppxlib_traverse_builtins.T.map_with_context
583583+ end
584584+585585+ module Lift : sig
586586+ type ('a, 'b) t = ('a, 'b) Ppxlib_traverse_builtins.T.lift
587587+ end
588588+589589+ module Lift_map_with_context : sig
590590+ type ('a, 'b, 'c) t = ('a, 'b, 'c) Ppxlib_traverse_builtins.T.lift_map_with_context
591591+ end
592592+ end
593593+594594+ class virtual map : object
595595+ inherit Ppxlib_ast.Ast.map
596596+ inherit Jane_street_extensions0(Ts.Map).t
597597+ end
598598+599599+ class virtual iter : object
600600+ inherit Ppxlib_ast.Ast.iter
601601+ inherit Jane_street_extensions0(Ts.Iter).t
602602+ end
603603+604604+ class virtual ['ctx] fold : object
605605+ inherit ['ctx] Ppxlib_ast.Ast.fold
606606+ inherit ['ctx] Jane_street_extensions0_ctx(Ts.Fold).t
607607+ end
608608+609609+ class virtual ['ctx] fold_map : object
610610+ inherit ['ctx] Ppxlib_ast.Ast.fold_map
611611+ inherit ['ctx] Jane_street_extensions0_ctx(Ts.Fold_map).t
612612+ end
613613+614614+ class virtual ['ctx] map_with_context : object
615615+ inherit ['ctx] Ppxlib_ast.Ast.map_with_context
616616+ inherit ['ctx] Jane_street_extensions0_ctx(Ts.Map_with_context).t
617617+ end
618618+619619+ class virtual ['res] lift : object
620620+ inherit ['res] Ppxlib_ast.Ast.lift
621621+ inherit ['res] Jane_street_extensions1(Ts.Lift).t
622622+ end
623623+624624+ class virtual ['ctx, 'res] lift_map_with_context : object
625625+ inherit ['ctx, 'res] Ppxlib_ast.Ast.lift_map_with_context
626626+ inherit ['ctx, 'res] Jane_street_extensions1_ctx(Ts.Lift_map_with_context).t
627627+ end
628628+end
+281
vendor/opam/ppxlib_jane/src/shim.mli.diff
···11+8,12d7
22+< (** When you change one of [shim.{ml,mli}], please also consider if you need to make
33+< changes to the corresponding [shim_upstream.{ml,mli}]. A diff between the mli files is
44+< automatically generated at [shim.mli.diff], so you'll find out if you change one but
55+< not the other *)
66+<
77+15c10
88+< type t = mode = Mode of string [@@unboxed]
99+---
1010+> type t = Mode of string [@@unboxed]
1111+27c22
1212+< type t = modality = Modality of string [@@unboxed]
1313+---
1414+> type t = Modality of string [@@unboxed]
1515+38c33
1616+< type t = include_kind =
1717+---
1818+> type t =
1919+67c62
2020+< type t = constructor_argument
2121+---
2222+> type t = core_type
2323+106c101
2424+< type t = module_declaration =
2525+---
2626+> type t =
2727+129c124
2828+< type nonrec jkind_annotation_desc = jkind_annotation_desc =
2929+---
3030+> type jkind_annotation_desc =
3131+137c132
3232+< type nonrec jkind_annotation = jkind_annotation =
3333+---
3434+> and jkind_annotation =
3535+143c138
3636+< type t = type_declaration =
3737+---
3838+> type t =
3939+161c156
4040+< type t = constant =
4141+---
4242+> type t =
4343+176c171
4444+< type nonrec function_param_desc = function_param_desc =
4545+---
4646+> type function_param_desc =
4747+180c175
4848+< type nonrec function_param = function_param =
4949+---
5050+> type function_param =
5151+185c180
5252+< type nonrec type_constraint = type_constraint =
5353+---
5454+> type type_constraint =
5555+190c185
5656+< type t = function_constraint =
5757+---
5858+> type t =
5959+200c195
6060+< type nonrec function_body = function_body =
6161+---
6262+> type function_body =
6363+216c211
6464+< type nonrec index_kind = index_kind =
6565+---
6666+> type index_kind =
6767+224c219
6868+< type nonrec block_access = block_access =
6969+---
7070+> type block_access =
7171+229c224
7272+< type nonrec unboxed_access = unboxed_access = Uaccess_unboxed_field of Longident.t loc
7373+---
7474+> type unboxed_access = Uaccess_unboxed_field of Longident.t loc
7575+232c227
7676+< type t = core_type_desc =
7777+---
7878+> type t =
7979+255c250
8080+< type t = core_type =
8181+---
8282+> type t =
8383+267c262
8484+< type t = pattern_desc =
8585+---
8686+> type t =
8787+295c290,297
8888+< type t = expression_desc =
8989+---
9090+>
9191+> type comprehension_expression = private
9292+> | Pcomp_list_comprehension of unit
9393+> | Pcomp_array_comprehension of unit
9494+>
9595+> type t =
9696+352c354
9797+< type t = type_kind =
9898+---
9999+> type t =
100100+378c380
101101+< type 'a t = 'a include_infos =
102102+---
103103+> type 'a t =
104104+390c392
105105+< type t = signature_item_desc =
106106+---
107107+> type t =
108108+414c416
109109+< type t = signature =
110110+---
111111+> type t =
112112+425c427
113113+< type t = structure_item_desc =
114114+---
115115+> type t =
116116+448c450
117117+< type t = functor_parameter =
118118+---
119119+> type t =
120120+457c459
121121+< type t = module_type_desc =
122122+---
123123+> type t =
124124+472c474,479
125125+< type t = module_expr_desc =
126126+---
127127+>
128128+> type module_instance = private Module_instance
129129+>
130130+> type t =
131131+487,492c494,511
132132+< class virtual map : Ppxlib_ast.Ast.map
133133+< class virtual iter : Ppxlib_ast.Ast.iter
134134+< class virtual ['acc] fold : ['acc] Ppxlib_ast.Ast.fold
135135+< class virtual ['acc] fold_map : ['acc] Ppxlib_ast.Ast.fold_map
136136+< class virtual ['ctx] map_with_context : ['ctx] Ppxlib_ast.Ast.map_with_context
137137+< class virtual ['res] lift : ['res] Ppxlib_ast.Ast.lift
138138+---
139139+> module Jane_street_extensions0 (T : sig
140140+> type 'a t
141141+> end) : sig
142142+> class type t = object
143143+> method jkind_annotation : jkind_annotation T.t
144144+> method jkind_annotation_desc : jkind_annotation_desc T.t
145145+> method function_body : Pexp_function.function_body T.t
146146+> method function_param : Pexp_function.function_param T.t
147147+> method function_param_desc : Pexp_function.function_param_desc T.t
148148+> method function_constraint : Pexp_function.Function_constraint.t T.t
149149+> method type_constraint : Pexp_function.type_constraint T.t
150150+> method mode : Mode.t T.t
151151+> method modes : Modes.t T.t
152152+> method modality : Modality.t T.t
153153+> method modalities : Modalities.t T.t
154154+> method signature_items : signature_item list T.t
155155+> end
156156+> end
157157+494,495c513,633
158158+< class virtual ['ctx, 'res] lift_map_with_context :
159159+< ['ctx, 'res] Ppxlib_ast.Ast.lift_map_with_context
160160+---
161161+> module Jane_street_extensions0_ctx (T : sig
162162+> type ('a, 'b) t
163163+> end) : sig
164164+> class type ['ctx] t = object
165165+> method jkind_annotation : ('ctx, jkind_annotation) T.t
166166+> method jkind_annotation_desc : ('ctx, jkind_annotation_desc) T.t
167167+> method function_body : ('ctx, Pexp_function.function_body) T.t
168168+> method function_param : ('ctx, Pexp_function.function_param) T.t
169169+> method function_param_desc : ('ctx, Pexp_function.function_param_desc) T.t
170170+> method function_constraint : ('ctx, Pexp_function.Function_constraint.t) T.t
171171+> method type_constraint : ('ctx, Pexp_function.type_constraint) T.t
172172+> method mode : ('ctx, Mode.t) T.t
173173+> method modes : ('ctx, Modes.t) T.t
174174+> method modality : ('ctx, Modality.t) T.t
175175+> method modalities : ('ctx, Modalities.t) T.t
176176+> method signature_items : ('ctx, signature_item list) T.t
177177+> end
178178+> end
179179+>
180180+> module Jane_street_extensions1 (T : sig
181181+> type ('a, 'b) t
182182+> end) : sig
183183+> class type ['a] t = object
184184+> method jkind_annotation : (jkind_annotation, 'a) T.t
185185+> method jkind_annotation_desc : (jkind_annotation_desc, 'a) T.t
186186+> method function_body : (Pexp_function.function_body, 'a) T.t
187187+> method function_param : (Pexp_function.function_param, 'a) T.t
188188+> method function_param_desc : (Pexp_function.function_param_desc, 'a) T.t
189189+> method function_constraint : (Pexp_function.Function_constraint.t, 'a) T.t
190190+> method type_constraint : (Pexp_function.type_constraint, 'a) T.t
191191+> method mode : (Mode.t, 'a) T.t
192192+> method modes : (Modes.t, 'a) T.t
193193+> method modality : (Modality.t, 'a) T.t
194194+> method modalities : (Modalities.t, 'a) T.t
195195+> method signature_items : (signature_item list, 'a) T.t
196196+> end
197197+> end
198198+>
199199+> module Jane_street_extensions1_ctx (T : sig
200200+> type ('a, 'b, 'c) t
201201+> end) : sig
202202+> class type ['ctx, 'res] t = object
203203+> method jkind_annotation : ('ctx, jkind_annotation, 'res) T.t
204204+> method jkind_annotation_desc : ('ctx, jkind_annotation_desc, 'res) T.t
205205+> method function_body : ('ctx, Pexp_function.function_body, 'res) T.t
206206+> method function_param : ('ctx, Pexp_function.function_param, 'res) T.t
207207+> method function_param_desc : ('ctx, Pexp_function.function_param_desc, 'res) T.t
208208+> method function_constraint : ('ctx, Pexp_function.Function_constraint.t, 'res) T.t
209209+> method type_constraint : ('ctx, Pexp_function.type_constraint, 'res) T.t
210210+> method mode : ('ctx, Mode.t, 'res) T.t
211211+> method modes : ('ctx, Modes.t, 'res) T.t
212212+> method modality : ('ctx, Modality.t, 'res) T.t
213213+> method modalities : ('ctx, Modalities.t, 'res) T.t
214214+> method signature_items : ('ctx, signature_item list, 'res) T.t
215215+> end
216216+> end
217217+>
218218+> module Ts : sig
219219+> module Map : sig
220220+> type 'a t = 'a Ppxlib_traverse_builtins.T.map
221221+> end
222222+>
223223+> module Iter : sig
224224+> type 'a t = 'a Ppxlib_traverse_builtins.T.iter
225225+> end
226226+>
227227+> module Fold : sig
228228+> type ('a, 'b) t = ('b, 'a) Ppxlib_traverse_builtins.T.fold
229229+> end
230230+>
231231+> module Fold_map : sig
232232+> type ('a, 'b) t = ('b, 'a) Ppxlib_traverse_builtins.T.fold_map
233233+> end
234234+>
235235+> module Map_with_context : sig
236236+> type ('a, 'b) t = ('a, 'b) Ppxlib_traverse_builtins.T.map_with_context
237237+> end
238238+>
239239+> module Lift : sig
240240+> type ('a, 'b) t = ('a, 'b) Ppxlib_traverse_builtins.T.lift
241241+> end
242242+>
243243+> module Lift_map_with_context : sig
244244+> type ('a, 'b, 'c) t = ('a, 'b, 'c) Ppxlib_traverse_builtins.T.lift_map_with_context
245245+> end
246246+> end
247247+>
248248+> class virtual map : object
249249+> inherit Ppxlib_ast.Ast.map
250250+> inherit Jane_street_extensions0(Ts.Map).t
251251+> end
252252+>
253253+> class virtual iter : object
254254+> inherit Ppxlib_ast.Ast.iter
255255+> inherit Jane_street_extensions0(Ts.Iter).t
256256+> end
257257+>
258258+> class virtual ['ctx] fold : object
259259+> inherit ['ctx] Ppxlib_ast.Ast.fold
260260+> inherit ['ctx] Jane_street_extensions0_ctx(Ts.Fold).t
261261+> end
262262+>
263263+> class virtual ['ctx] fold_map : object
264264+> inherit ['ctx] Ppxlib_ast.Ast.fold_map
265265+> inherit ['ctx] Jane_street_extensions0_ctx(Ts.Fold_map).t
266266+> end
267267+>
268268+> class virtual ['ctx] map_with_context : object
269269+> inherit ['ctx] Ppxlib_ast.Ast.map_with_context
270270+> inherit ['ctx] Jane_street_extensions0_ctx(Ts.Map_with_context).t
271271+> end
272272+>
273273+> class virtual ['res] lift : object
274274+> inherit ['res] Ppxlib_ast.Ast.lift
275275+> inherit ['res] Jane_street_extensions1(Ts.Lift).t
276276+> end
277277+>
278278+> class virtual ['ctx, 'res] lift_map_with_context : object
279279+> inherit ['ctx, 'res] Ppxlib_ast.Ast.lift_map_with_context
280280+> inherit ['ctx, 'res] Jane_street_extensions1_ctx(Ts.Lift_map_with_context).t
281281+> end