There is a great article here that talks about 3 very common and useful monads: Reader
, Writer
and State
.
The Reader
monad allows a common context (ie. DAO object) to be threaded through to chained functions. A common use for this type of monad is dependency injection.
http://eed3si9n.com/learning-scalaz/Reader.html
http://blog.originate.com/blog/2013/10/21/reader-monad-for-dependency-injection/
The Writer
monad is used to keep a running log of chained computations. For instance, if you have multiple arithmetic functions chained together, the writer class can append to the log each time a computation is run, and the final result will contain both the final value of the computations, as well as the complete log.
http://eed3si9n.com/learning-scalaz/Writer.html
http://www.lispplusplus.com/2011/10/scala-writer-monad.html
http://blog.tmorris.net/posts/the-writer-monad-using-scala-example/
The State
monad can be seen as similar to the reader monad, except that the state can be modified throughout the call chain, whereas the reader's context can only be read.
http://eed3si9n.com/learning-scalaz/State.html
https://softwarecorner.wordpress.com/2013/08/29/scalaz-state-monad/