Functor, Applicative and Monad: A Summary of Functional Containers
This article examines how three functional containers – Functor, Monad, and Applicative – relate to one another.
This piece wraps up my series on category theory. Here I turn the spotlight on how the three functional containers covered earlier – Functor, Monad, and Applicative – relate to each other.
I compare them below with respect to:
- Theory
- Laws
- Methods
- Possibilities & Use Cases
Theory
Functor
Category theory defines a Functor as a mapping from one category to another.
In programming, a Functor can be thought of as a utility class that lets us apply a mapping operation to values wrapped in a context. It can also be seen as an interface that guarantees a specific capability – being able to transform an object’s state. In languages with a stronger functional focus, such as Scala or Haskell, Functor is a typeclass.
Functors come in several kinds. Describing and analyzing them in depth goes well beyond this article, but don’t worry – I’ve included links to further resources that will help you learn more.
Kinds of Functors:
- Contravariant Functor
- Invariant Functor
- Opposite Functor
- Bifunctor & Multifunctor
Java and other modern JVM languages don’t offer any good built-in equivalents of Functors. Still, writing one by hand is fairly simple. The closest equivalents are probably the one in the Scala library Cats and the one in Haskell.
Applicative
In category theory, an Applicative (also called an Applicative Functor) generalizes a Functor: it lets us operate not only on values in a context but also on functions in a context.
When it comes to expressive power, it lies between Functors and Monads. Applicatives are weaker than Monads but have more structure than Functors.
Strictly speaking, Applicatives don’t let us chain operations the way Monads do, where the result of one operation feeds into the next. Unlike Functors, however, Applicatives do let us sequence computations.
Sadly, such a relationship is rather difficult to achieve in software, because ultimately the underlying data ends up as the input of the next operation.
Monad
In software terms, we can see it as a wrapper that places our value in a context and lets us run operations on that value – specifically, operations whose results are wrapped in the Monadic context.
Monads mainly serve to handle side effects of every kind:
- Running I/O operations
- Dealing with operations that may throw exceptions
- Dealing with async operations
It’s also worth noting that operations can be chained so that the result of each step becomes the input of the following one. This lets us write highly declarative code with little boilerplate.
Unlike Functor, Monad has plenty of built-in implementations in modern programming languages:
- Scala (Option, Try, Either, … and others)
- Haskell (IO, …. and others ),
- Java (Optional, not strictly a Monad, but nearly one)
Both in practice and in theory, it is also the most powerful of the three concepts. Ordered by pure mathematical power, from the weakest to the strongest, the full hierarchy looks roughly like this:

Laws
Functor
A Functor implementation has to satisfy two laws: Identity and Associativity
1. Identity
Mapping the values inside the Functor with the identity function must always give back the value unchanged.
2. Associativity
When functions are applied in a chain, the way they are nested must not matter.
Applicative
An Applicative implementation has to satisfy four laws: Identity, Homomorphism, Interchange, Composition.
1. Identity
Applying the identity function to a value in the context must always give back the value unchanged.
2. Homomorphism
Applying a function in a context to a value in a context must produce the same result as applying the function to the value and then wrapping the result in the context using pure.
3. Interchange
Applying a function with context f to a value with context must be equivalent to applying the wrapped function – one that passes the value as an argument to another function – to the function with context f.
4. Composition
Applying the function with context f followed by the function with context g must yield the same results as applying the composition of f and g inside the context.
Alternative Applicative
There is also an equivalent formulation of Applicative, whose implementation has to satisfy three laws: Associativity, Left Identity, and Right Identity.
1. Left identity
Creating a new Applicative and binding it to the function must give the same result as applying the function to the value.
2. Right identity
Binding a unit function to the Applicative must give the same result as creating a new Applicative.
3. Associativity
When functions are applied in a chain, the way they are nested must not matter.
Looking more closely at the laws of this formulation of Applicative, you’ll see they match the Functor laws. The difference in the Identity Law comes from how the two concepts are set up – especially from the presence of the pure method in Applicative, which in a sense means there is one more case to verify.
Monad
A Monad implementation has to satisfy three laws: Left Identity, Right Identity, and Associativity.
1. Left identity
Creating a new Monad and binding it to the function must give the same result as applying the function to the value.
2. Right identity
Binding a unit function to a Monad must give the same result as creating a new Monad.
3. Associativity
When functions are applied in a chain, the way they are nested must not matter.
Just like with Applicative, the Monads Laws closely resemble the Functor laws. Moreover, the Monad Laws are identical to the Applicative Laws – only the concept the Laws describe differs, while the condition stays the same.
In terms of which concept extends which, the relationship between the three looks roughly like the picture below – in short, everything is a Functor.

Methods
Implementing any of these structures requires a language that supports generics, since each of them is built on a parameterized type M<T>. Alternatively, you could generate code for every needed type with a macro or a similar construct, but generics make it much easier.
Functor
A Functor, requires just one method:
- map, which takes a function operating on the value in the context. Its signature should be M<R> (T -> R).

Applicative
An Applicative requires two methods:
- pure, which wraps your value in the Applicative context; its signature is M<T>(T).
- apply (ap), which takes a function in a context; that function then operates on the value in the context. Its signature should be M<U> (M<T -> U>).

Alternative Applicative
An equivalent formulation of Applicative also exists, in which product replaces apply.
- product, which takes two separate values wrapped in the Applicative context and returns a context holding both of them. Its signature should be M<(T, U)>(M<T>, M<U>).

With either formulation of Applicatives, a map method with the signature M<R> (T -> R) comes by definition, since every Applicative is a Functor.
Monad
A Monad requires two methods:
- unit (of,), which wraps the value in the Monad context; its signature is M<T>(T).
- bind (flatMap), which takes a function operating on the value in the context, where the result is already wrapped in the Monad context. Its signature should be M<U> (T -> M<U>).

Furthermore, a Monad is an Applicative too and therefore also a Functor. This means we get many extra methods at no cost – namely map from Functor and apply or product from Applicative.
The possibilities & use cases
Functor
A Functor is merely a utility method. All it offers is plain mapping of a value inside some arbitrary context.
At the same time, it is the simplest and most approachable of the three concepts and fits nearly anywhere we need to operate on values in a context.
That said, Functors do have limits. By definition, a Functor cannot chain computations. It also offers no way to flatten the results of the operations it performs, so nested types such as <List<List<Long>> can appear easily.

Still, being able to run effectful operations without taking them out of the context is a genuinely useful feature.
Applicative
One step further is the Applicative, which lets us apply functions in a context to a value in a context. On top of that, its product variant lets us build a tuple from two objects in the same context.
This can be extremely handy in certain situations – we can combine many effects into a single one, turning types like List<Future> into the more sensible Future<List>.
This is why Applicatives work very well for implementing things like parsers, traversables, or composers, and for any other case where we deal with many independent effects of the same type.
And since the Applicative is a Functor, we can also run operations on these output tuples using the map method.
Monad
Finally, there’s the Monad – the strongest of the three structures.
Every Monad implementation stands for an effect:
- absence of a value (Option)
- a potential failure (Try)
- either the result or the failure of an operation (Either)
- a sequence of computations (IO)
Monad also provides a way to place values in such an effectful context.
What’s more, the flatMap method lets us deal with nested return types, which in turn removes the problems with types shaped like M<M<T>> (Optional<Optional<Long>).

A Monad implementation flattens such types automatically so that just one effect remains – something the map method of a Functor cannot do by definition.

Monads, also let us perform contextual operations, since the output of one operation can serve as the input of another, giving us a clean, declarative chain of computations.
Summary
Functional containers are a highly practical tool that can solve many different problems. I believe they deserve a spot in our engineering toolbox – or at least our awareness. Just keep in mind that they aren’t a silver bullet, and turning everything into a Monad may not be the best approach to writing code.
On a final note, these containers bring a bit more mathematical elegance into software engineering – yet another reason to appreciate them, in my view.
I hope you enjoyed reading this. Thanks for your time.