package ppx_repr
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=36db1188217a8b0ad3c5c745f120ac1a46ff1767a6440988bd7280e68e751850
sha512=c7399f64b8bdc5b0aad63b66feb6142096b9b72bc27aee94d8896d780271d0dadbf242f09b1a92cc2b1a4f29e2ca5db08f77d1ebeb0ee5761c61a031a3ca3657
doc/ppx_repr.lib/Ppx_repr_lib/Algebraic/Located/argument-1-S/index.html
Parameter Located.S
module Located : sig ... end
include sig ... end
val loc : Ppxlib.Location.t
val class_infos :
virt:Migrate_parsetree__.Ast_410.Asttypes.virtual_flag ->
params:
(Migrate_parsetree__.Ast_410.Parsetree.core_type
* Migrate_parsetree__.Ast_410.Asttypes.variance)
list ->
name:string Ppxlib_ast__.Import.Location.loc ->
expr:'a ->
'a Migrate_parsetree__.Ast_410.Parsetree.class_infos
val pexp_for :
Migrate_parsetree__.Ast_410.Parsetree.pattern ->
Migrate_parsetree__.Ast_410.Parsetree.expression ->
Migrate_parsetree__.Ast_410.Parsetree.expression ->
Migrate_parsetree__.Ast_410.Asttypes.direction_flag ->
Migrate_parsetree__.Ast_410.Parsetree.expression ->
Migrate_parsetree__.Ast_410.Parsetree.expression
val location :
start:Lexing.position ->
end_:Lexing.position ->
ghost:bool ->
Ppxlib_ast__.Import.Location.t
val position :
fname:string ->
lnum:int ->
bol:int ->
cnum:int ->
Lexing.position
val type_declaration :
name:string Ppxlib_ast__.Import.Location.loc ->
params:
(Migrate_parsetree__.Ast_410.Parsetree.core_type
* Migrate_parsetree__.Ast_410.Asttypes.variance)
list ->
cstrs:
(Migrate_parsetree__.Ast_410.Parsetree.core_type
* Migrate_parsetree__.Ast_410.Parsetree.core_type
* Ppxlib_ast__.Import.Location.t)
list ->
kind:Migrate_parsetree__.Ast_410.Parsetree.type_kind ->
private_:Migrate_parsetree__.Ast_410.Asttypes.private_flag ->
manifest:Migrate_parsetree__.Ast_410.Parsetree.core_type option ->
Migrate_parsetree__.Ast_410.Parsetree.type_declaration
val type_extension :
path:Ppxlib_ast__.Import.Longident.t Ppxlib_ast__.Import.Location.loc ->
params:
(Migrate_parsetree__.Ast_410.Parsetree.core_type
* Migrate_parsetree__.Ast_410.Asttypes.variance)
list ->
constructors:Migrate_parsetree__.Ast_410.Parsetree.extension_constructor list ->
private_:Migrate_parsetree__.Ast_410.Asttypes.private_flag ->
Migrate_parsetree__.Ast_410.Parsetree.type_extension
evar id
produces a Pexp_ident _
expression, it parses its input so you can pass any dot-separated identifier, for instance: evar ~loc "Foo.bar"
.
val eapply :
Migrate_parsetree__.Ast_410.Parsetree.expression ->
Migrate_parsetree__.Ast_410.Parsetree.expression list ->
Migrate_parsetree__.Ast_410.Parsetree.expression
Same as pexp_apply but without labels
val pstr_value_list :
loc:Ppxlib.Location.t ->
Ppxlib_ast.Asttypes.rec_flag ->
Migrate_parsetree__.Ast_410.Parsetree.value_binding list ->
Migrate_parsetree__.Ast_410.Parsetree.structure_item list
pstr_value_list ~loc rf vbs
= pstr_value ~loc rf vbs
if vbs <> []
, []
otherwise.
val nonrec_type_declaration :
name:string Ppxlib.Loc.t ->
params:
(Migrate_parsetree__.Ast_410.Parsetree.core_type
* Ppxlib_ast.Asttypes.variance)
list ->
cstrs:
(Migrate_parsetree__.Ast_410.Parsetree.core_type
* Migrate_parsetree__.Ast_410.Parsetree.core_type
* Ppxlib.Location.t)
list ->
kind:Migrate_parsetree__.Ast_410.Parsetree.type_kind ->
private_:Ppxlib_ast.Asttypes.private_flag ->
manifest:Migrate_parsetree__.Ast_410.Parsetree.core_type option ->
Migrate_parsetree__.Ast_410.Parsetree.type_declaration
val unapplied_type_constr_conv :
Ppxlib.Longident.t Ppxlib.Loc.t ->
f:(string -> string) ->
Migrate_parsetree__.Ast_410.Parsetree.expression
unapplied_type_constr_conv
is the standard way to map identifiers to conversion fonctions, for preprocessor that creates values that follow the structure of types. More precisely, path_conv path (sprintf "sexp_of_%s")
is:
- sexp_of_t if path is "t"
- A.B.sexp_of_foo if path is "A.B.foo"
- A.B.sexp_of_f__foo (module A1) (module A2) if path is "A.B.F(A1)(A2).foo"
type_constr_conv
also applies it to a list of expression, which both prevents the compiler from allocating useless closures, and almost always what is needed, since type constructors are always applied.
val type_constr_conv :
Ppxlib.Longident.t Ppxlib.Loc.t ->
f:(string -> string) ->
Migrate_parsetree__.Ast_410.Parsetree.expression list ->
Migrate_parsetree__.Ast_410.Parsetree.expression
val eta_reduce :
Migrate_parsetree__.Ast_410.Parsetree.expression ->
Migrate_parsetree__.Ast_410.Parsetree.expression option
Tries to simplify fun v1 v2 .. -> f v1 v2 ..
into f
. Only works when f
is a path, not an arbitrary expression as that would change the meaning of the code. This can be used either for cleaning up the generated code, or to reduce allocation if f
is a local variable (the compiler won't optimize the allocation of the closure).
Eta-reduction can change the types/behavior in some corner cases that are unlikely to show up in generated code:
- if
f
has optional arguments, eta-expandingf
can drop them - because labels commute, it can change the type of an expression: $ let f ~x y = x + y let f2 = fun x -> add x;; val f : x:int -> int -> int = <fun> val f2 : int -> x:int -> int = <fun> In fact, if
f
does side effects before receiving all its arguments, and if the eta-expansion is partially applied, eta-reducing could change behavior.
eta_reduce_if_possible_and_nonrec
is meant for the case where the resulting expression is going to be bound in a potentially recursive let-binding, where we have to keep the eta-expansion when rec_flag
is Recursive
to avoid a compile error.