3 ms·
It’s essentially a way to give types to “mutable” views into larger data structures. s - the larger data structure a - a view value b - a “update” value t -
by dmkolobov 2y ago
It’s essentially a way to give types to “mutable” views into larger data structures.
s - the larger data structure
a - a view value
b - a “update” value
t - the data structure after an update is applied
Of course, everything is still immutable in the same way that cons-ing a value onto a list is immutable.
The change in type between s and t allows you to nest these views, hide information, etc.
- _jackdk_ 2y agoYou've got the right general idea but the difference between `s` and `t` is not for nesting - you can write a composition operator for a "simple" lens where s=t and a=b. `b` and `t` are just for type-changing updates, like when you replace a field in a tuple or every element in a list.