Internals

Accessors.insertmacroMethod
insertmacro(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.

source
Accessors.mappropertiesMethod
mapproperties(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

source
Accessors.opticcomposeMethod
opticcompose([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.

source
Accessors.opticmacroMethod
opticmacro(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.

source
Accessors.setmacroMethod
setmacro(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.

source