Monad, Functor and Applicatives in Swift

Higher-kinded

Steven Curtis
6 min readFeb 28, 2022
Photo by Alejandro Piñero Amerio on Unsplash

I looked at many articles that copy-paste an original Haskell blog post (Simon Peyton Jones not involved, unfortunately) and felt unfulfilled (and requires understanding of optionals under the hood) without explaining them. Here is an article that gives a hand with those rather heavy prerequisites!

This gives the advantage of creating complex, composable functional slices of code.

The following explanation moves from the Swift standard library to higher-kinded types.

Prerequisites

None

Keywords and Terminology

Applicative: A structure that allows for functional computations to be sequenced, while not allowing results from previous results to be used in the definition of subsequent results

Functor: A design pattern that allows for a generic type to apply a function inside without changing the structure of the generic type

--

--