Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Do you have a link, this sounds extremely interesting.

I've just started reading Adowey's category theory book, it's amazing when you start to notice the same basic fundamental structures everywhere!



No specific link. My primary interest in the topic is very applied; primarily in bidirectional data binding expressions mapping data and business objects to UI controls, possibly over a transport.

A lens is just a pair of (setter, getter). It's a first-class reference that you can pass around, much like you'd pass around a pointer to a location; except you can transform it. If you use bijective functions to do the transformation, you can wrap both the getter and setter, one with the function and the other with its inverse. These lenses are a little like pipes, wormholes or ducts that are attached at one end to your model / data layer / business layer / wherever.

I simply plugged them into the UI, and added some extra control information for reactive UI updates at the web application server request / response boundary. The upshot was that the user could poke at the UI, a request would be sent down effectively addressing that particular lens endpoint, business logic as necessary would run, and then the minimal UI update would come back in the response - only lenses whose values had changed would be sent back. The business logic never had to specifically tell the UI which bits needed to be refreshed; the bits that needed to be sent were inferred automatically.

I wrote a data-binding language specifically to implement this scheme. It was called Gravity, in part because it accreted more and more responsibility in the system :)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: