Veit's Blog

Let’s Build Lenses in Carp, Part II: Prisms

05/09/2020

In a sequel to a video from earlier this week on lenses we’re going to look at how to extend our library to work with prisms, and find out what prisms are in the process.

If you didn’t watch the first session yet, I highly encourage you to do so before diving into this video, because we’re going to build on the library we started there and extend it.

I left my references on the bottom of the page if you want to dig a little deeper—they are the same resources I linked to the last time.

Download link

References

  1. Profunctor Optics: Modular Data Accessors by Matthew Pickering et al.: this is great if you want to learn the real theory behind lenses and prisms, and optics in general. It is not great if you don’t want to read 50 pages about that topic.
  2. Lenses embody Products, Prisms embody Sums by Justin Le: this blog post is a very detailed and deep dive into lenses and prisms, using Haskell as the vehicle. It explains why our implementation is theoretically unsound and how to rectify that. It is also more advanced than my screencast.