|
|
|
|
|
by przemo_li
1836 days ago
|
|
IO is also pure. It will not be executed until the very last line of your app. O_O No seriously. If you wanted to model IO in say Java. Your whole program would be about constructing values. No I/O what so ever. Only do this then that then get a, then if a is this do x other..... Whole Java app and I/O would only happen when at the very end you execute run method on that constructed value. That'd not usual Java. After all in Java code itself can do control flow and I/O. Do why bother with those values. Need I/O on line ten out of 100. Do I/O immediately on line 10. What I/O on Haskell is is side effect. Explicit side effect. It's possible to write impure code in Haskell but that is not IO. It's when you use escape hatches that break type system guarantees. |
|