Hacker News new | ask | show | jobs
by Sonata 1893 days ago
The important thing is that it separates the order of side-effects from the order of evaluation of expressions. This isn't a particularly important distinction in an imperative language, but in a functional language when you introduce things like laziness and memoization, the order in which expressions will be evaluated is not obvious.

Because pure I/O preserves referential transparency, it gives the compiler far more ability the optimize the code by changing how, when and whether things are evaluated, while still being able to prove that it has not modified the external behaviour of the program.

Haskell doesn't use pure I/O out of zealotry - without it, Haskell couldn't and be lazy-by-default and the compiled code would probably be much slower.

1 comments

Thank you, that's a great, practical answer. "We have to do this to make lazy evaluation, memoization, etc work" is very sensible and not ideological at all. That makes sense.
It's also functional core-imperative shell built-in, and optimized for functional expressions.