4 ms·
Immutability as absense of over-writes or mutations of existing values (in Erlang one just introduces a new binding for a new value) is obviously enough. Stat
by dschiptsov 11y ago
Immutability as absense of over-writes or mutations of existing values (in Erlang one just introduces a new binding for a new value) is obviously enough.
State and I/O is easily incapsulable inside closures with CPS or with explicit message passing.
For a lazy language one needs some ADT, like Monad, for explicitly "enforcing" a strict order of evaluation for a specific set of expressions, because I/O implies a strict order. Think of it as a transformation from a set to sequence (by defining an order as an ADT).
Lifting State or IO into Monadic world is mere a trick to satisfy a typechecker and enforce a strict order by using an ADT. A strict language with optional lazynes could use ordinary type-tags.
Nothing to see here.
- marcosdumay 11y ago> A strict language with optional lazynes could use ordinary type-tags. And then you'll have a total order, that makes your code hard to parallelize. But more important, it mixes state updating (that can be actually done in several orders, can be rewinded, and has several other interesting properties) with IO, with list mapping, with exception handling, and everything else.