
I'm, analysing the IO-system of the GHC and need more information about it. More precisely: How switches the run-time-system between (normal) evaluation and performing of IO-actions?
I read the rts-paper, but didn't find any information about this.
Can somebody give a short review, or are ther any other papers available?
The runtime system mostly has no concept of IO vs. non-IO evaluation. The IO monad is implemented as the following type: newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #) which means that an IO action is simply a function from the world state to a pair of a new world state and a value. In other words, it's a straightfoward state monad, except that we use some optimised representations to eliminate some of the overhead of passing the state around. Cheers, Simon