I'm not convinced lack of side effects is the thing that lets you build tools that prompt removal of code in this way. In OCaml, if you had an unused variable like in the example you would get a compiler warning about it, and 99% of the time the compiler is right that you should delete the code. It's perfectly possible in principle that computing the value could have side effects. But in good (OCaml) code, you should very rarely have functions that have side effects and return a value other than unit. So the compiler is almost always right in practice (and you can still use side effects when you want to interact with the outside world, which is handy).