| ▲ | rowbin 11 hours ago | |
Since the monad structure itself carries some inherent information, that is how "side effect" information can be carried outside of the actual data and be part of the monad structure instead. So e.g. the Maybe monad. It either has data or it does not have data. The information whether carries data or not lives outside the data itself. Or the list monad carries information on how many data points it carries and the order of the data points without that being being part of the actual data it holds. This is how "side effect" information is carried outside the actual information the monad is carrying. Real side effects like writing to disk however are not real monads. The IO monad pretends to be a real monad but it's not. It just helps with hiding the impurity of IO from the pure parts of Haskell. So one might think about the IO monad kind of like the list monad where the order of the IO operations is encapsulated. It kind of pretends that the IO part is pure and deterministic when its actually not in order to have a somewhat clean separation between pure and non pure parts of the program. Hope that helps. | ||
| ▲ | rowbin 10 hours ago | parent [-] | |
So the answer to your questions: 1. Is answered in the parent comment 2. It's not really about solving problems directly. Its more about a common way to hold meta information about your data. But of course that might help you with approaching similar problems. 3. Thats hard. You dont really think about it that way. Again its not really the type of problems directly. Its more about similar approaches to solving different kinds of problems. So you can use monads for solving basically any problem. But you can also choose to not use monads to solve the problem. This is something you'll need to get a feel for. And it shouldn't be for first line of thought. When solving a problem you might recognize that a certain monad lends itself to solving the problem. But it's not really something you actively go looking for. | ||