Julien Richard-Foy’s blog

A bottom up approach to category theory: Functors

This post is the first of a series attempting to give an intuitive idea of some “objects” taken from category theory and applied to programming: Functors, Applicative Functors and Monads. I’ll try to follow a practical, bottom-up approach rather than explaining the abstract concepts first and then how to derive them in programming. I will just follow a very basic programming principle to see the emergence of these objects: generalizing problems. Let’s start with Functors.

Imagine you are writing a Web application to manage contacts. The domain model can be represented by the following Contact datatype: