Lenses are used in functional programming, and you’re probably using them without noticing!
As per the metaphor, a lens allows us to focus on a specific part (
U) of a larger object (
Use case, please!
Lenses are especially useful when updating a subpart of an object in a context of immutability.
In the following example, we’re willing to update only the
speed of a…