Purity Analysis is like tackling the Halting Problem, making it impossible to statically analyze in all cases. There will always exist countless functions that evade your purity checker's ability to classify them as pure or impure.
This leaves any potential purity checker with only two options:
- Err on the side of caution by rejecting any function that cannot be definitively proven pure. This leads to an endless list of pure functions being barred from use.
- Allow any function that lacks clear proof of being impure. Consequently, there are numerous impure functions that can slip through the cracks of the checker.
The ideal solution lies in constructing a language, type system, and libraries with pure intentions from the start. By doing so, there may be a chance to conduct automatic purity checks more effectively. Although checking for purity universally remains unattainable, the groundwork for easy verification can enhance the usefulness of the checker.
An alternative approach could involve creating a language that prohibits writing impure functions altogether, but this would limit its practicality. As one of Haskell's creators once mentioned: a purely functional program accomplishes nothing other than generating heat within the CPU. To which someone quipped from the audience: even heating up the CPU qualifies as a side-effect!