lens represents the process of focusing on a specific part of a data structure.
We represent this via a
view function and
set function, roughly corresponding to object-oriented
"getters" and "setters" respectively.
Lenses can be composed to access or modify deeply nested
A function that takes a data structure of a certain type and returns a subpart of that structure
A function that takes a data structure of a certain type
and a value and returns a new data structure with the given subpart
replaced with the given value. Note that
Lenses are popular in functional programming because they allow you to build pure, compositional, and re-usable "getters" and "setters".
As noted in the README, using
lens directly incurs the following obligations
(the "Lens laws"):
Get-Put: If you get (view) some data with a lens, and then modify (set) the data with that value, you get the input data back.
Put-Get: If you put (set) a value into some data with a lens, then get that value with the lens, you get back what you put in.
Put-Put: If you put a value into some data with a lens, and then put another value with the same lens, it's the same as only doing the second put.
"Lenses" which do not satisfy these properties should be documented accordingly. By convention, such objects present in this library are suffixed by "_il" ("illegal lens").
1 2 3 4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.