A Focus is a way to work with particular parts of a large chunk of data. On the most basic level, it lets you get
and set
fields of a record in a simple and composable way. This means you could avoid writing special record update syntax and use something that composes much more elegantly.
This API is inspired by the concept of Bidirectional Lenses as described by Nate Foster and seen in a modified form in Haskell as "lenses" and in ClojureScript as "cursors". My personal opinions and understanding comes from this talk by Simon Peyton Jones, discussions with @seliopou, and a basic understanding of Nate Foster's PhD thesis on bidirectional lenses. I chose the name "Focus" for this outline because it is sort of like a lens that only lets you see in one direction.
Here's the pseudocode that describes the basic API:
modul