The "Handling State" series
In this series of posts, I’ll look at how you can thread state through a series of pure functions in a convenient way.
To start with, I’ll tell the story of Dr Frankenfunctor and the Monadster, and how the Doctor needed a way to create “recipes” that were activated when lightning struck.
The Doctor then devised ways to work with these recipes using functions such as map, bind and apply.
In the final post, we’ll see how we can use a computation expression to make the coding cleaner, and how these techniques can be generalized into the so-called “state monad”.
Warning! These posts contains gruesome topics, strained analogies, discussion of monads
-
1. Dr Frankenfunctor and the Monadster
Or, how a 19th century scientist nearly invented the state monad -
2. Completing the body of the Monadster
Dr Frankenfunctor and the Monadster, part 2 -
3. Refactoring the Monadster
Dr Frankenfunctor and the Monadster, part 3