Duality and How to Delete Half (minus ε)...
There’s a prefix that shows up a lot in Haskell: “co-”. There are “comonads” and “coalgebras” and “covariant functors” … wait a second, that last one means something different than the others. But what, and how? I’ll explain the concept of duality (at least in category theory, you’re on your own for metaphysics) and distinguish it from often confused concepts like variance and isomorphisms. Duality often seems too abstract to be useful, but it can help us in a variety of ways, and we can take advantage of it to simplify (and even eliminate) writing certain kinds of code. While not all the components exist in Scala yet, we’ll discuss what is there and how it can be used to automate building some useful constructions. I am porting a tool for programmatically generating dual constructions that I wrote in Haskell (https://github.com/sellout/dualizer) to Scala. It can hopefully both reduce the amount of code you write and give you a new way to explore category theory.