Adding superpowers to a custom type
In modern Android and with the advent of Kotlin, functional programming is integrating into our everyday code bit by bit. Do we take full advantage of this paradigm though? In this article, I will explain, how a relative common nowadays type like
Result<T> can be “powered up” to become a monad and help via composition, to solve different problems.
What is a monad ❓
To begin with, let us see what a monad is. Wikipedia, states as a definition:
Software development nowadays is a complex process that while entailing many scientific aspects, it can also be seen as a form of art. Even rules and best practices aside, a piece of code will always mirror the mind, soul and creativity of the developer that created it. As such a developer can always benefit from borrowing elements and studying great masters, not only of Computer Science, but of other arts too, such as the art of storytelling. After all, a craftsman must keep honing their skills.
Programming and storytelling are very similar in nature. For example, both are expressed via…
Passion driven software engineer with the mission to constantly provide value, while crafting a unique story along the way. Android developer at heart.