O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Applicative Functors

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 with 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), and suppose 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.

In other words, Applicative Functors enable us to put a function inside ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required