package ppxlib

  1. Overview
  2. Docs
Standard library for ppx rewriters

Install

Dune Dependency

Authors

Maintainers

Sources

ppxlib-0.18.0.tbz
sha256=9d483c36467ae061c70df7166ed1465eadcc3442aefa760fb5c5439bf8047dc3
sha512=b1a9faff8f190f78600fe33762a32362eae457a09dbcb35b58eb897dc7915d1c228df818a3e698a8cca19d40a2ec422a860620d3468dfa1feeee78eb0b2e8445

doc/ppxlib/Ppxlib/Extension/index.html

Module Ppxlib.Extension

type (_, _) equality =
  1. | Eq : ('a, 'a) equality
  2. | Ne : (_, _) equality
module Context : sig ... end
type t

Type of declared extensions.

val declare : string -> 'context Context.t -> (Migrate_parsetree.Ast_411.Parsetree.payload, 'a, 'context) Ast_pattern.t -> (loc:Location.t -> path:string -> 'a) -> t

declare name context pattern expander declares the extension names name for context.

expander is responsible for producing the code to replace the extension in the AST. It receives as argument:

  • loc: the location of the enclosing node. For instance for expression it is the pexp_loc field
  • path: the current module path
val declare_with_path_arg : string -> 'context Context.t -> (Migrate_parsetree.Ast_411.Parsetree.payload, 'a, 'context) Ast_pattern.t -> (loc:Location.t -> path:string -> arg:Longident.t Ppxlib__.Import.Asttypes.loc option -> 'a) -> t

Same as declare except that the extension name takes an additional path argument. The path is the part of the name that start with a capitalized component. For instance in the following, the extension "map" would receive the path argument Foo.Bar:

  let%map.Foo.Bar x = 1 in
  ...
val declare_inline : string -> 'context Context.t -> (Migrate_parsetree.Ast_411.Parsetree.payload, 'a, 'context list) Ast_pattern.t -> (loc:Location.t -> path:string -> 'a) -> t

Inline the result of the expansion into its parent. Only works for these contexts:

  • class_field
  • class_type_field
  • signature_item
  • structure_item
val declare_inline_with_path_arg : string -> 'context Context.t -> (Migrate_parsetree.Ast_411.Parsetree.payload, 'a, 'context list) Ast_pattern.t -> (loc:Location.t -> path:string -> arg:Longident.t Ppxlib__.Import.Asttypes.loc option -> 'a) -> t
module For_context : sig ... end

This module is used to implement Context_free.V1.map_top_down

val filter_by_context : 'a Context.t -> t list -> 'a For_context.t list

Given a context and a list of extension expander, returns all the ones that are for this context.

module Expert : sig ... end

This module allows to declare extensions that do not produce a value of the context type. This is typically useful for extensions point that depends on more things from the context than the path and location.

val check_unused : Ast_traverse.iter
module V2 : sig ... end
module V3 : sig ... end
OCaml

Innovation. Community. Security.