3 ms·
How does laziness keep you honest about side effects exactly? If anything, eager evaluation will reveal the bug faster.
by hota_mazi 9y ago
How does laziness keep you honest about side effects exactly?
If anything, eager evaluation will reveal the bug faster.
- kerkeslager 9y agoSide effects aren't a bug, in most programs, but they are impure (and purity is the main goal of Haskell). So if Simon Peyton Jones or someone else introduces code that causes side effects, in an eagerly-evaluated pure language like ML, it might not be obvious, because programs that use the impure code can behave as expected. But if you introduce side effects to a lazy language like Haskell, the side effects will happen at the wrong time, or not at all, making it immediately obvious that your code has side effects, and SPJ can replace the impure code with pure code that returns a description of the side effects, which are then evaluated by the runtime, as Haskell intended side effects to be handled.