Internals
Accessors.insertmacro
— Methodinsertmacro(optictransform, ex::Expr; overwrite::Bool=false)
This function can be used to create a customized variant of @insert
. It works by applying optictransform
to the optic that is used in the customized @insert
macro at runtime.
Example
function mytransform(optic::Lens)::Lens
...
end
macro myinsert(ex)
insertmacro(mytransform, ex)
end
See also opticmacro
, setmacro
.
Accessors.mapproperties
— Methodmapproperties(f, obj)
Construct a copy of obj
, with each property replaced by the result of applying f
to it.
julia> using Accessors
julia> obj = (a=1, b=2);
julia> Accessors.mapproperties(x -> x+1, obj)
(a = 2, b = 3)
Implementation
This function should not be overloaded directly. Instead both of
ConstructionBase.getproperties
ConstructionBase.setproperties
should be overloaded. This function/type is experimental. It can be changed or deleted at any point without warning
Accessors.opticcompose
— Methodopticcompose([optic₁, [optic₂, [optic₃, ...]]])
Compose optic₁
, optic₂
etc. There is one subtle point here: While the two composition orders (optic₁ ⨟ optic₂) ⨟ optic₃
and optic₁ ⨟ (optic₂ ⨟ optic₃)
have equivalent semantics, their performance may not be the same.
The opticcompose
function tries to use a composition order, that the compiler likes. The composition order is therefore not part of the stable API.
Accessors.opticmacro
— Methodopticmacro(optictransform, ex::Expr)
This function can be used to create a customized variant of @optic
. It works by applying optictransform
to the created optic at runtime.
# new_optic = mytransform(optic)
macro myoptic(ex)
opticmacro(mytransform, ex)
end
See also setmacro
.
Accessors.setmacro
— Methodsetmacro(optictransform, ex::Expr; overwrite::Bool=false)
This function can be used to create a customized variant of @set
. It works by applying optictransform
to the optic that is used in the customized @set
macro at runtime.
Example
function mytransform(optic::Lens)::Lens
...
end
macro myset(ex)
setmacro(mytransform, ex)
end
See also opticmacro
.