When using ADTs in our code base, it can be difficult to use common debugging tools like watches and breakpoints. This is mainly due to the common pattern of using compositions and other ways of manipulating how functions are called. This can cause us to have to revert to using console logs at the different points in our flow, to peek at how our data is changing over time. When using ADTs this gets even further complicated by the fact that we typically need ways to lift our logging functions into the type.
To get a handle on one way to approach debugging, we’ll look at a logAfter
function that is a must in any Functional Programmer’s toolkit. Using logAfter
we’ll hunt down a bug currently in our code base and once located, squash that bug out of existence.