keen/lens
SourceThis is a standard module
and does not need to be explicitly imported.
lens[outer, inner] interfaceget inner(a outer)set outer(a outer, b inner)get[t, u] u(outer t, lens (t, u) lens)Use the lens to get the value. This simply changes the argument order for the 'get' function on the lens interface for better readability.
set[t, u] t(outer t, lens (t, u) lens, inner u)Use the lens to set the value. This simply changes the argument order for the 'get' function on the lens interface for better readability.
modify[t, u] t(outer t, lens (t, u) lens, f u mut(u))Use the lens to get the value, modify it, then set the new value.
+[t, u, v] (t, (u, v)) lens(a (t, u) lens, b (t, v) lens) t data, u data, v dataLens that gets or sets two things as a tuple. For the setter, this sets
a first before setting b. Generally you should use this with orthogonal properties so that the order doesn't matter.