Blog of Alexander Semenov
Structuring real-world code using monadic abstractions
In this article I present a simple relatively boilerplate-free approach to structuring Scala code using monadic abstractions. I use cats but it can be done using any other library, like Scalaz.
Introduction
Presented approach is nothing new but just well-known patterns used in a cohesive way. In a sense it tries to compete . . .
Monads
...from programmer's perspective
What is a monad
Monad is a trait with the following operations:
Having such trait implementation for a type M
makes it a monad instance.
Sometimes, pure
is called return
or point
, whereas bind
might instead be named flatMap
(preferred in Scala) or >>=
(Haskell's way). The method names are not so . . .