4 ms·
Monads are a way of reifying and manipulating context. If that context includes a background mutable state model, then yes. Monads are more useful than just for
by tel 14y ago
Monads are a way of reifying and manipulating context. If that context includes a background mutable state model, then yes. Monads are more useful than just for providing mutable state.
That said, your example is just a constant function, not a monad at all.
The point of monads wrt. mutable state is not that they hide it—indeed they uncover it and make it more explicit. I have to exactly specify where my code makes mutable or world-observable changes. Furthermore, through explicitness I can now manipulate, compose, adjust these abilities very flexibly.