3 ms·
Logging with timestamps is not in opposition to purity. All purity does is force you to change the type of a function that wants to log something, to reflect t
by runeks 9y ago
Logging with timestamps is not in opposition to purity.
All purity does is force you to change the type of a function that wants to log something, to reflect that it’s returning a value that, when evaluated at run-time, will have the side-effect of printing to the console. It’s still a pure function since it returns the same description given the same argument(s), the only difference is that when this description is evaluated by the run-time system, something will be printed to the console (in accordance with the description).
In other words, you’re not restricting the effects your program can have, only how you can choose to describe them (as first-class values whose evaluation has a side-effect that is not observable by your code).
It’s all explained perfectly in this talk: https://www.infoq.com/presentations/io-functional-side-effects#.WfRR_6ZtSbY.hackernews https://www.infoq.com/presentations/io-functional-side-effec...