Meta_deriving.PluginA Plugin.t is a pair of functions that extend a representable type with specialised generic operations: one to supply the implementation of the specialistion, and one to supply its type.
For instance, the generic operation equal : 'a Repr.t -> 'a -> 'a -> equal could be packaged as the following plugin:
create
~intf:(fun loc t -> [%type: [%t t] -> [%t t] -> bool])
~impl:(fun loc t -> [%expr Repr.unstage (Repr.equal [%e t])])That is:
t, its equality function has type t -> t -> bool,t, we can derive an equality function via Repr.equal.val create :
?type_name:[ `before | `after ] ->
impl:(Ppxlib.location -> Ppxlib.expression -> Ppxlib.expression) ->
intf:(Ppxlib.location -> Ppxlib.core_type -> Ppxlib.core_type) ->
string ->
tval derive_str :
t ->
loc:Ppxlib.location ->
type_name:string ->
params:string list ->
expr:Ppxlib.expression ->
Ppxlib.structure_itemval derive_sig :
t ->
loc:Ppxlib.location ->
type_name:string ->
params:Ppxlib.core_type list ->
ctyp:Ppxlib.core_type ->
Ppxlib.signature_itemval defaults : t listDefault set of plugins, using the generic operations provided by Repr.