I made an optics library called "Ocular Patdown" that features a match
-like DSL for performing deep immutable updates.
Example:
> (update (list 1 2 3)
[(list a b c)
(set! a #t)
(modify! b -)])
'(#t -2 3)
It works by creating a tree of composed optics for a pattern, with leaves binding an optic that focuses on that location within the target value.
The DSL is implemented using syntax-spec
.
This is also an optics library, currently featuring lenses, traversals, prisms, and isomorphisms. But the update language is the coolest part IMO, and it's why I made the library.
This is the first library I've ever published, so I'd love to hear feedback! Hope you find it interesting.