Hacker News new | ask | show | jobs
by rkts 6285 days ago
Ok, you're right. That is a better explanation of monads than the one I gave.

I intended my example to represent cases where you want real mutation, in the sense of modifying a data structure in place. Your code using the State monad, if I understand it correctly, just abstracts functional updates in a way that looks like mutation.

Anyway, my intent in my original comment was simply to explain the practical consequences of pure functional programming. That, for instance, if you have a pure function that you want to randomize, this change must be reflected in all the code that depends on it. My intuition is that this is a bad thing, but I don't have enough experience to say for sure. However, it is apparent to me that purity

1. adds a lot of complexity to the language, and

2. has no clear practical benefits,

which is why I say it's a waste of time.