AccessorsExtra.jl
Advanced optics/lenses and tools for immutable data structure manipulation, extending Accessors.jl.
Install / Use
/learn @JuliaAPlavin/AccessorsExtra.jlREADME
AccessorsExtra.jl
Advanced optics/lenses and relevant tools, based on the Accessors.jl framework.
The Accessors.jl package defines a unified interface to modify immutable data structures — so-called optics or lenses. See its docs for details and background.
AccessorsExtra.jl defines more optics and relevant tools that are too involved/opinionated/experimental to be included into a package as foundational as Accessors itself.
Following Accessors itself, optics and operations in AccessorsExtra aim to have as little overhead as possible, often zero, with tests checking this.
Some highlights:
julia> obj = (a=1, b=(2, 3, "4"))
# multi-valued optics
julia> o = @o (_.a, _.b[2])
julia> o(obj)
(1, 3)
julia> @set o(obj) = (:x, :y)
(a = :x, b = (2, :y, "4"))
# recursive optics
julia> o = RecursiveOfType(Number)
julia> getall(obj, o)
(1, 2, 3)
julia> modify(x -> x+1, obj, o)
(a = 2, b = (3, 4, "4"))
# optional optics: maybe()
julia> o = maybe(@o _.b[2])
julia> o(obj)
3
julia> o((a=1, c=3))
nothing
# optional optics: @oget
julia> @oget obj.a
1
julia> @oget obj.c
nothing
julia> @oget obj.b[10]
nothing
julia> @oget obj.c obj.b[10] obj.b[1] # returns the first found value
2
See the Pluto notebook for more details and usage examples.
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
