3 ms·
Local impurity. The key insight is that mutation/impurity isn't necessarily bad in and of itself. The important thing is that it is guaranteed to not cross API
by kqr 7y ago
Local impurity. The key insight is that mutation/impurity isn't necessarily bad in and of itself. The important thing is that it is guaranteed to not cross API boundaries -- this prevents abstractions from leaking at least one way, and lets you reason about the code as if it were pure. (And in fact, from the outside it is.)
This allows mutation to remain the performance optimisation it is, without allowing it to seep into the design of systems, which is where it causes badness.
As far as I know, Haskell is one of the few languages (if not the only one) that supports local mutation that is guaranteed to not be visible in any way to the caller.