3 ms·
That's the whole point of Haskell's separate IO type, and while there are other ways to compose IO values, the usual "do notation" creates a clear visual differ
by lmm 4y ago
That's the whole point of Haskell's separate IO type, and while there are other ways to compose IO values, the usual "do notation" creates a clear visual difference (but not too different) between statements (using <-) and expressions (using =).
- revskill 4y agoInteresting to know. Do you know how the evaluation in IO Monad actually work ?
- lmm 4y agoIn theory, Haskell evaluates by graph-reduction, hence its lazy semantics, and then after evaluating a program to an IO value it interprets that, similarly to how e.g. a free monad + interpreter pattern would run. In practice Haskell-98 generally gets lowered into a simple form that can then be executed directly, and the IO monad is represented as effectively the state monad where the state is a marker token that represents the real world. In actual practice real-world Haskell IO with async etc. gets run in various ad-hoc ways that seem to work but aren't necessarily principled.