4 ms·
Interesting to know. Do you know how the evaluation in IO Monad actually work ?
by revskill 4y ago
Interesting 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.