4 ms·
Do we even need side effects? Most programs seem to be about transforming some input to an output and/or storing/retrieving state in a transactional manner. Per
by somewhereoutth 7y ago
Do we even need side effects? Most programs seem to be about transforming some input to an output and/or storing/retrieving state in a transactional manner. Perhaps I/O and transactional storage could be kept outside a language and instead be managed by its containing environment?
For example, console I/O: The input from the console could be transformed (possibly with some state) and sent back out (possibly triggering an associated state update) as a fairly natural pure function call. It would have the type state -> input -> (state', output), and the 'runtime' would be responsible for gluing this all together.
- AnimalMuppet 7y agoSuppose it's not the console. Suppose it's a disk file. You can write to it. You can read back in what you wrote out. That means it's a giant global state. If I understand correctly, writing to it cannot be pure.