I can write a State Monad (in Scala/Java) and can pretty much follow the logic when I see others using it. I don't fully understand the problem it is solving. It is a monad wrapping the funciton S => (S,A)
.
As such, when you nest functions that result in a State Monad via flatMap it gives you a set of instructions/operations to perform on the data (S)
(but hasn't executed them yet). Not until the very end, when you give it an S
and tell it to run, does it do work.
What are the benefits of doing this versus just writing functions to pretty much do the same thing?
Monads don't compose, so having these functions in this way seems to have large implications for design. Please, if you provide code for an example, use Java or Scala (as I don't understand how to read Haskell or other strictly Functional languages). hanks!