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

Monads

A Monad is a type of Functor, a type that, along with map, implements the flatMap function. It is simple, right? We have a Functor with an extra functionality, and that's the flatMap implementation. So, any types that we can call map and flatMap functions over are Monads. Arrays and optionals are examples of Monads.

Monads are Functors with flatMap functions! In the following sections, we will talk about map and flatMap functions.

So far, we have learned that Functors are structures with map functions. Applicative Functors are Functors with apply functions and Monads are Functors with flatMap functions. Now, let's talk about these important functions.

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