What are lenses used/useful for?

They offer a clean abstraction over data updates, and are never really “needed.” They just let you reason about a problem in a different way. In some imperative/”object-oriented” programming languages like C, you have the familiar concept of some collection of values (let’s call them “structs”) and ways to label each value in the collection … Read more

Sneaking lenses and CPS past the value restriction

The value restriction is a limitation of the OCaml type system that prevents some polymorphic values from being generalized, i.e. having a type that is universally quantified over all type variables. This is done to preserve soundness of the type system in the presence of mutable references and side effects. In your case, the value … Read more