This is F# code, and my first version was monadic, modular, but flat. In some sense I was using the monadic abstraction as a comfort zone but without pushing it. Now I have "internalized" the concept and "objectified" it to the point where I am comfortable to program mostly without the "do" notation, composing higher order monadic constructions. And this brings me to my favorite pattern of the moment: the monadic fold.
Here is how it works:
- the fold pattern is "joining" an operator accross a slice of data. In effect it is a universal "block" but which is "projected" against existing data, see each fold as an new inner hierarchy in your code.
- the monadic environment supports the "environmental" needs of the operators