We explore a means to represent the combination of our stateful computations using familiar composition. We dive into what makes this possible by talking about what are known as Kleisli Arrows and explore some interesting properties surrounding them.
Once we understand the basics of how our stateful computations are chained, we look at how we can enlist a special compose helper named composeK
. Using composeK
, we show how we can further remove a lot of the boilerplate sometimes used to combine stateful computations.
The composeK
refactoring at the end is beautiful, and I wouldn't have appreciated it without seeing it long-form. Well played.