http://blog.jle.im/entry/the-compromiseless-reconciliation-of-i-o-and-purity
Input and output are inherently stateful.
No, it's not, and creating this pretend distinction leads to all sorts of errors in practice.
It is inappropriate to discuss why this is wrong in this gist.
This is because there is nothing more "inherent" in the "statefulness" of IO than there is in any other arbitrary monad. The distinction being offered here is fallacious. A free monad encoding demonstrates this fact, among other demonstrations.
To properly point out why this fact is false, it would be appropriate to explore a free monad encoding of arbitrary grammars; using IO, not using IO and using both, then observing nil difference in "inherent statefulness." Repeat this process until the above statement is debunked accordingly.
There are also other techniques to demonstrate why it is false, but this is usually enough for any honest student.
Also, consider a function generating random numbers [violating purity]
https://github.com/NICTA/rng "This library provides the ability for a user to generate random values of arbitrary type. It provides a pure-functional interface to preserve equational reasoning."
Of course, this “program” doesn’t actually do anything.
Setting the reader up to also make the same errors and develop the same misunderstandings. The program referred to definitely does do something.
IO a represents a computation that returns something of type a.
This error is not a small one. Nor is it in any way an approximation, or some useful inaccuracy.
Note that this has nothing to do with execution. printFibN does not execute a print statement.
This error is built on previous errors. Degree of error is compounding.
What will happen is that print won’t print the result of getStringFromStdin. print will print out the representation of the computation!
I think I am going to stop here. This article is quite erroneous and invites the reader to develop the same misunderstanding as the author. It offers very little in the way of accurate explanation that assists the reader in developing an understanding of the concepts involved.