These notes discuss the simultaneous use of generalised fold operators and monads to structure functional programs. Generalised fold operators structure programs after the decomposition of the value they consume. Monads structure programs after the computation of the value they produce. Our programs abstract both from the recursive processing of their input as well as from the side-effects in computing their output. We show how generalised monadic folds aid in calculating an efficient graph reduction engine from an inefficient specification.
['Erik Meijer', 'Johan Jeuring']
Merging Monads and Folds for Functional Programming