Applicative Functor

The name of Applicative Functor also comes from the category theory and we can think of an Applicative Functor as a functional design pattern.

An Applicative Functor is a Functor equipped with a function that takes a value to an instance of a Functor containing that value. Applicative Functors provide us the ability to operate on not just values, but values in a functorial context, such as optionals, without needing to unwrap or map over their contents.

Let's suppose that we have an optional Functor (an optional that has the map function). We cannot directly apply the map function on optionals as we need to unwrap them first. Applicative Functors come to the rescue. They add a new function, for instance, apply to the Functor to make it possible to apply map on the Functor. Again, unlike its name, the concept is simple; we will talk about the apply function in an upcoming section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset