A match-like DSL for deep immutable updates

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)

Here are the docs

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.

4 Likes

As someone who has written too many optics libraries, let me just say that this is exceptionally cool.

2 Likes

Nothing of note from me, but the make-iso had me delighted, haha, because it's such a nice idea.

Thanks for sharing!


Edit: oops.

1 Like