Summary
This appendix has taken us on a brief tour of the world of category theory. We learned three of its abstractions: Functors, Applicative Functors, and Monads. They were the guiding principle behind imminent's API.
To deepen our knowledge and understanding, we implemented our own Option Monad, a common abstraction used to safely handle the absence of values.
We have also seen that using these abstractions allow us to make some assumptions about our code, as seen in functions such as alift
. There are many other functions we would normally rewrite over and over again for different purposes, but that can be reused if we recognize our code fits into one of the abstractions learned.
Finally, I hope this encourages readers to explore category theory more, as it will undoubtedly change the way you think. And if I can be so bold, I hope this will also change the way you design libraries in the future.