A Menagerie of Monads (Hard Core) [Part one]
This one-day, fast-moving workshop will help you answer both “how do I use Monads” as well as “why and when do I use them.”
We’ll begin with the familiar Array and Optional examples for map and flatMap as a way to motivate the definitions of and differences between Functors and Monads.
We’ll then explore examples of monads such as the State monad, the logging monad, and futures to see why we need both map and flatMap.
We’ll end the day by looking at an important function that lives between map and flatMap: apply.
By the end of the day you should have a strong mental model of Monads, Applicatives, and Functors and see how you might use them in your shipping applications to simplify your code.
A Menagerie of Monads Syllabus
The actual contents may vary on the day of training but the likely topics are:
* Map in the standard library
* FlatMap in the standard library
* Pure and the connection between map and flatMap
* Functors, Monads, and a brief look at Applicative Functors
* The Result type – chaining steps together
* The State monad – using a random number generator example
* The Logging monad – generating a log as we go
* Futures – a look at asynchronous coding