The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Sumant Tambe (17) [Avatar] Offline
#1
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.

Also
val.log()
should not be passed to the function f. Instead,
val.value()
should be passed.

This discussion appears relevant: https://stackoverflow.com/a/22140063
Ivan Cukic (104) [Avatar] Offline
#2
I agree this can be misleading to people who know Reader/Writer/State monads. Will see what to do about this.

Thanks!