Sumant Tambe (17) [Avatar] Offline
Looking at the title of section 10.6 (Handling state with Monads), I thought State monad will be discussed. The first 5 paragraphs in this section strongly suggest that the intention is to discuss the idea of mutable state as implemented in pure-functional languages--via a state monad. However, it looks like the examples are of the Writer monad. As the name "Writer monad" won’t say much to a C++ programmer, could this section be called something else? Like Log-Appending monad. That’s not catchy though.

I think this section should not confuse with state monad as the computation is NOT dependent on existence of a state. Usage of an empty std::string in the constructor of with_log confirms that a monoid is used.

should not be passed to the function f. Instead,
should be passed.

This discussion appears relevant:
Ivan Cukic (94) [Avatar] Offline
I agree this can be misleading to people who know Reader/Writer/State monads. Will see what to do about this.