A quick mockup of a probably marginally useful lens implementation in 80 lines of code. This is incredibly rudimentary, as the whole point is to provide a more convenient technique for in-place updating of deep fields -- writing a flat sequence of lenses instead of an unwieldy tree of getters and setters. This is not meant to implement full optics in a rigorous fashion, so we only have set
, get
, and (as a bonus) over
. You won't find any prisms or traversals or isomorphisms here.
Lenses compose with a nice syntax, and lenses are simple to write by hand. The goal was to create a convenient syntax to create lenses and compose them, with ease of usage a simple bonus.