Optics for F#


Optics (often referred to as lenses, although the area is broader) are an often overlooked but very useful tool in functional programming. Used well, they can reduce the amount of code we have to write significantly, as well as making operations clearer and more readable.

To start understanding the what, and importantly the why, the introduction to Lenses is a good place to start. This is best followed by a useful companion to lenses when we’re dealing with data which implies uncertainty, Prisms. We also dive in to Morphisms, another hugely useful tool for making it easy to work with data in more usable forms.

Additionally, a section on some of the behavioural Laws that we expect from optics is included for those interested.

A useful list of links to other places discussing lenses is also given.