This is what state monads are doing anyway under a hidden syntax, and for simple cases it may be easier that building a full dedicated monad.
This is what state monads are doing anyway under a hidden syntax, and for simple cases it may be easier that building a full dedicated monad.