Member-only story

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

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (1)

Write a response

"which is so much shorter"
- true
" and, I hope, easier to understand"
- I doubt
Not even counting issues with line breakpoints or rebase conflicts on such one-man show, do-it-all-on-single-line code.
One of main goals for a good code is readability…

--