The idea is that your state is a big data structure. You use lenses to focus in and display certain parts, then use those lenses to update parts when events are triggered.
The lens connection is definitely elegant. I particularly like the (obvious once you see it) property of (profunctor) lenses that they give you free composition operators for anything which looks like p a b for some strong profunctor p.
The Traversal part was what really impressed me, however. OpticUI has captured the (type-safe!) essence of something like KnockoutJS in a few dozen lines.
I saw this comment and figured I could read the article and present a summary here. Turns out, I don’t know enough Haskell (specifically Lens) jargon either. My best guess is that this is an experimental alternative to React that handles state like Om. That means it has one top-level mutable state value, but individual components are only aware of their “local” state.
The “Bananas, Lenses” paper is a naming collision; its lenses are called that because of the syntax the authors chose, and they’re unrelated to van Laarhoven lenses.
I think this might be interesting, but I feel like I don’t know enough Haskell jargon to make sense of it.
Here’s the referenced PureScript implementation of the idea:
https://github.com/zrho/purescript-optic-ui
The idea is that your state is a big data structure. You use lenses to focus in and display certain parts, then use those lenses to update parts when events are triggered.
The lens connection is definitely elegant. I particularly like the (obvious once you see it) property of (profunctor) lenses that they give you free composition operators for anything which looks like
p a bfor some strong profunctorp.The
Traversalpart was what really impressed me, however. OpticUI has captured the (type-safe!) essence of something like KnockoutJS in a few dozen lines.I saw this comment and figured I could read the article and present a summary here. Turns out, I don’t know enough Haskell (specifically Lens) jargon either. My best guess is that this is an experimental alternative to React that handles state like Om. That means it has one top-level mutable state value, but individual components are only aware of their “local” state.
Yeah, I agree. Are the lenses they’re talking about the same ones that come with barbed wire, or are those lenses unrelated lenses?
I have never heard of barbed wire with respect to lenses. Is that a reference to Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire? I have not read that. The lenses in this post are van Laarhoven lenses, specifically the
lenspackage.The “Bananas, Lenses” paper is a naming collision; its lenses are called that because of the syntax the authors chose, and they’re unrelated to van Laarhoven lenses.
Thank you!