Functor >> Applicative >> Monad

Functional programming is out there. Partly rumor, partly practiced, partly understood. I have been writing about them for around 6 months. In this post, I want to summarize the main terminologies (jargons) very concisely, with example and best of all, with swift code. For a full explanation, I will link to my previous blogs and external resources as we go along. Lets get going.

Read More

Exploring FP: Nomad's Monoid

What is a Monoid? Monoid is a property of a system which satisfies these three laws: Has identity Is composable and the order of composition doesnot matter: i.e. composition is associative The result of composing 2 such system produces similar system. i.e Closure property or endomorphism. Well, that sounds a bit abstract. Indeed. Well, is this any useful in programming? You bet it is. This post is entirely about understanding what a monoid is, with ideas we (OOP) programmers already know.

Read More

Monadic Computation in Swift. Why?

I won’t go into the details of what a Monad is and what exactly it solves. What we will do here is try to come up with a monadic type to encapsulate network result. We will do a side by side comparison with the traditional/classical/imperative and the functional (monadic) approach. In the end you should be able to appreciate and hopefully use the monadic style of wrapping network result without being bothered about the nitty gritty details of what a monad is?

Read More

Functor: Mapping over things!

Prelude Specialization is the key to mastery; functional programming specializes only on function. Thats all there is. The mastery with FP is to reduce complexity, which is what software engineering is all about. Don’t get me wrong, Software engineering is also about delivering product not only over engineering. Delivering real world products used to be the stressful part about functional programming. Not anymore. Specialization on functions creates a whole new paradigm.

Read More