Summary
In this chapter, we discussed functors and their role in functional programming. We started with the basics, explaining that functors are like smart containers. They can hold data and also apply a function to that data while keeping their original shape.
We looked at how functors work, showing how they let us run functions on the data they hold without needing to unpack and repack the container. We also covered the two main rules that functors follow: the Identity and Composition laws.
Through examples, we saw how functors can be used in different situations, such as working with lists or handling errors more smoothly. We explored creating our own functors, which opens up new ways to tailor our code to fit exactly what we need. We made the full journey from functors to applicative functors and monads, learned about the laws that each of these “containers” adhere to, and saw them in some practical scenarios.
As we wrap up this chapter, you should have...