Starting with unsafePerformIO
and ending with RTS, libc or OS API, how does GHC implement IO?
I am trying to understand how IO works in Haskell when the standard foreplay is not available (for example, if we ourselves used the standard foreplay for any reason).
I originally expected to find wrapped calls to C functions in GHC Haskell code, but that is not the case. unsafePerformIO
built on top of runRW#
where the heavy magic begins, and we begin to crumble into functions and types that are not implemented in Haskell and are instead built into the compiler. runRW#
seems to be able to trigger an IO action in a real world state (i.e. a State# RealWorld
).
Trying to go from another direction, I did not find a bridgehead in RTS. It does not seem to contain calls that I would expect functions like fread()
and fwrite()
or read()
and write()
.
Where can I continue with IO implementation? What is the main roadmap from here onwards?
source
share