Functors, applicatives, and friends by Mark Seemann
Functors and related data structures are containers of values. It's a family of abstractions. An overview for object-oriented programmers.
This article series is part of an even larger series of articles about the relationship between design patterns and category theory.
If you've worked with C# or Java recently, you've most likely encountered types such as Foo<T>
or Bar<T>
(specifically, on .NET, e.g. List<T>). Perhaps you've also noticed that often, you can translate the type inside of the container. For example, if you have a Foo<string>
, perhaps you can call some method on it that returns a Foo<int>
. If so, it may be a functor.
Not all generic types are functors. In order to be a functor, a generic type must obey a couple of intuitive laws. You'll learn about those in future articles.
Some functors have extra capabilities, and you'll learn about some of those as well. Some are called applicative functors, and some are called bifunctors. There are others, as well.
All applicative functors are functors, and this is true for bifunctors as well.
In this article series, you'll learn about the following categories:
- Functors
- Applicative functors
- Bifunctors
- Contravariant functors
- Profunctors
- Invariant functors
- Monads
- Functor relationships
Next: Functors.