Advantages of a functor

It allows you to map over values without being tied to a specific structure.

Furthermore, all advantages of map over for loops apply to which is mainly compactness and expressiveness.

Applicative

An applicative is an extension of a functor and is used to be able to apply functors to each other. In order to do this, it wraps a function around the value which is wrapped by the functor. The required ap method is used to automatically apply the already partially applied and wrapped function via map to the wrapped value of another functor:

Generally speaking it creates a simple interface for complex code. However the real advantages can only be grasped if a specific applicative is used. General applicatives like the one described above are rather rare. Further information will be provided in the monad section.

Monads

A monad applies a function which returns a wrapped value to a wrapped value. The main advantage over applicatives is that they run sequentially by providing the chain method. Here is an implementation of a general monad:

It just checks whether the wrapped value is null or undefined and if it is, returns a wrapped null. Why is this interesting? Well, first of all it avoids pesky null checks. Additionally, it provides safety from runtime errors when chaining several methods where one may fail to return a value:

If one property in the path wouldn’t exist, we wouldn’t get an error but a Maybe with value null.

Right now you probably think you have a déjà vu and yes you are correct Promise is a monad.

Advantages of a monad

In general monads are concise and expressive with the ability to encapsulate side-effects.

The advantages of specific monads are as numerous as their implementations ranging from the simple forms of State ensuring the correct state flow, Sequence where ; can be a monad for control flow, Maybe handling null checks, Promise handling asynchronicity up to the complex ones of Probability Distribution or Transaction for databases.