Haskell
If you have searched for monads and reached this article, you probably have some degree of knowledge about monads. You may have already put a fair amount of effort into learning monads. In any way, whenever you’ve tried to learn monads, you have likely encountered two main approaches:
The: Monads are simple, here’s a simple example of a monad. Or the famous: A monad is a monoid in the category of endofunctors. In both approaches, the layout is similar. We start with a strong statement like: A monad is a powerful concept when applied to programming, and later apologize for being one of the most difficult programming concepts to grasp. The reality is that all of these statements about monads are valid, and the truth lies somewhere in the middle.
Disclaimer: Go is not a pure functional programming language. This article does not try to teach you functional programming in Go since imposing functional programming concepts, may result in unnecessarily awkward code. Go has its style, and it’s proven to be highly successful. Therefore, there’s no point in forcing a foreign dialect on Go code. Haskell would be a great choice if you want to express yourself functionally.
This article aims to provide imperative programmers a bridge to the functional world. Crossing that bridge and seeing the other side can help us reimagine problem-solving and add new skills to our set. We will encounter Go translations to some original Haskell code, hoping this will allow us to understand the original dialect.