
23 Dec
2008
23 Dec
'08
2:16 p.m.
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