Chris Ford's Lens Implementation


#1

Chris Ford’s Lens Implementation

Lenses are an interesting data structure for representing sub-value access and updates within a value. They compose well functionally. They are used in Haskell, where the type system gives a little help. But this implementation in Clojure is interesting and shows potential. See also these slides and this video (needs login or Twitter) for more information about Lenses.


#2

Here’s a simple one I wrote:

Lens in Clojure

It’s the second style, where Lens is no longer a data structure but a single function. Not sure about composition and its other uses, yet. It probably needs some tweaking.