package ppxlib

  1. Overview
  2. Docs

Deriving code from type declarations

module Args : sig ... end

Specification of generator arguments

Generator registration
type t

Type of registered derivers

module Generator : sig ... end
val add : ?str_type_decl: (Ppxlib_ast__.Import.Parsetree.structure_item list, Ppxlib_ast__.Import.Asttypes.rec_flag * Ppxlib_ast__.Import.Parsetree.type_declaration Base.List.t) Generator.t -> ?str_type_ext: (Ppxlib_ast__.Import.Parsetree.structure_item list, Ppxlib_ast__.Import.Parsetree.type_extension) Generator.t -> ?str_exception: (Ppxlib_ast__.Import.Parsetree.structure_item list, Ppxlib_ast__.Import.Parsetree.type_exception) Generator.t -> ?str_module_type_decl: (Ppxlib_ast__.Import.Parsetree.structure_item list, Ppxlib_ast__.Import.Parsetree.module_type_declaration) Generator.t -> ?sig_type_decl: (Ppxlib_ast__.Import.Parsetree.signature_item list, Ppxlib_ast__.Import.Asttypes.rec_flag * Ppxlib_ast__.Import.Parsetree.type_declaration Base.List.t) Generator.t -> ?sig_type_ext: (Ppxlib_ast__.Import.Parsetree.signature_item list, Ppxlib_ast__.Import.Parsetree.type_extension) Generator.t -> ?sig_exception: (Ppxlib_ast__.Import.Parsetree.signature_item list, Ppxlib_ast__.Import.Parsetree.type_exception) Generator.t -> ?sig_module_type_decl: (Ppxlib_ast__.Import.Parsetree.signature_item list, Ppxlib_ast__.Import.Parsetree.module_type_declaration) Generator.t -> ?extension: (loc:Location.t -> path:Base.String.t -> Ppxlib_ast__.Import.Parsetree.core_type -> Ppxlib_ast__.Import.Parsetree.expression) -> Base.String.t -> t

Register a new deriving generator.

The various arguments are for the various items on which derivers can be attached in structure and signatures.

We distinguish exception from type_extension as exception E is not exactly the same as type exn += E. Indeed if the type exn is redefined, then type exn += E will add E to the new exn type while exception E will add E to the predefined exn type.

extension register an expander for extension with the name of the deriver. This is here mostly to support the ppx_deriving backend.

val add_alias : Base.String.t -> ?str_type_decl:t Base.List.t -> ?str_type_ext:t Base.List.t -> ?str_exception:t Base.List.t -> ?str_module_type_decl:t Base.List.t -> ?sig_type_decl:t Base.List.t -> ?sig_type_ext:t Base.List.t -> ?sig_exception:t Base.List.t -> ?sig_module_type_decl:t Base.List.t -> t Base.List.t -> t

add_alias name set add an alias. When the user write the alias, all the generator of set will be used instead. It is possible to override the set for any of the context by passing the specific set in the approriate optional argument of add_alias.

val ignore : t -> Base.Unit.t

Ignore a deriver. So that one can write: Deriving.add ... |> Deriving.ignore

OCaml

Innovation. Community. Security.