Q:

How can IO cause side effects in Functional Programming?

Whenever I read about Haskell, I find that IO can cause side effects.
But I do not understand how it would do it?
Do we mean that we are writing to a file from one lazy sequence and another lazy sequence is reading from same file?
Is that the only possibility or is there something fundamentally deep?

A:

The Haskell optimizer is allowed to freely manipulate calls to pure functions as long as the result remains the same. For example, if it can see that you are calling sqrt on the same number 100 times, it can cache the returned value and only call it once. If it can see that you never actually use the result of that function, it can choose to not call it at all.
These things can't be done with IO. If you read from stdin 100 times, you wouldn't want to optimizer to cache the first read and reuse that value 99 more times. If you write to the console and discard the return value (because you don't actually care about the return value of putStrLn) you wouldn't want the optimizer to remove the function call altogether.
That's the meaning of side effects - not from the programmer's point of view (the programmer clearly meant for these things to happen) but from the optimizer's point of view.

A:

Simplest possible example: printing "Hello, world!" changes the state of the system, because the console now displays "Hello, world!", and earlier it didn't. Not only have you changed the state, it's actually impossible to change it back, since you can't un-get characters from a terminal! That's about the most serious side effect possible.

A:

I think the problem is that you are a bit unclear on what is meant by a side effect. In a pure function with no side effects, the function gives a result that is a direct result of the input and nothing else. In a function with side effects, the function depends on or changes the state of the outside world. So if you have a function like square(x), then that is a pure function. On the other hand, if you have function like launch_the_missiles(), then that has a very real side effect (or for a more mundane example, print a page).
So doing IO changes the state of the world, that is the side effect

