“A monad is a collection of functions that can be used to modify stepwise calculations.”
What did we read about?
This was our thirteenth week of ‘Functional Programming for the Object-Oriented Programmer‘ by Brian Manick.
We start from Page 121 “10 Branching and Looping in Dataflow Style” and read all the way through to Page 131 stopping at “10.5 Extending continuation-passing style”.
Going over the “->” and “let” functions again, we compare the linear/non-linear calculation of them both. We look at removing explicit branching through “monads”, which allow us to insert code after the computation steps in the normal flow of our code.
Finally we are introduced to the “continuation-passing style”, revolving around the idea of “flowing the result” of each step of our computation into the next. There are some Exercises to get you to grips with it and then we elaborate on how the style gets evaluated.
What stood out?
- “10.1 That pesky nil again” (Page 124) – A well worked example of doing nil checking automagically via the “with-monad” and “domonad”.
- “10.2 Continuation-passing style” (Page 126) – An interesting use of the “->” function which actually makes computation steps clearer.
If you read nothing else this week…
- Practice the continuation-passing style in Exercises 1 – 3 (Page 127).
- “10.4 Expansions in Evaluation” (Page 128) gets under the covers of continuation-passing style and how it gets evaluated. We compare this to how the “domonad” gets evaluated and how understanding both is critical to understanding how monads in general work.