[Haskell-cafe] What are side effects in Haskell?

Hans van Thiel hthiel.char at zonnet.nl
Tue Dec 23 09:16:29 EST 2008


Hello All,

I just saw somewhere that one of the purposes of monads is to capture
side effects. I understand what a side effect is in C, for example. Say
you want to switch the contents of two variables. Then you need a third
temporary variable to store an intermediate result. If this is global,
then it will be changed by the operation. 
But what is a side effect in an fp language like Haskell?
As a follow up, I understand why an IO action like getLine or getChar is
not a function; its results can be different for different calls. But
why not have something like getChar c or getLine str? The types of c or
str are pretty clear, aren't they?
Just something that's been puzzling me for some time now...thanks.

Regards,

Hans van Thiel



More information about the Haskell-Cafe mailing list