How is IO monad actually implemented?in sense of, what would be the actual implementation of the main function?
How would I call haskell function (IO) from another language and do I in that case need to maintain IO my self?
Does main pulls IO actions (Lazily) as references and then call them?
Or it is interpreter job, when it found actions in its way it can call them?
Or maybe something else?
Is there good IO monad implementation in different language which can help to deeply understand what happening in main function?
Edit:
Such hGetContents confuses me a lot, and makes me unsure how IO is really implemented.
Ok, let's say I have very simple pure Haskell interpreter witch unfortunately has no IO support and for curiosity I want to add this IO actions to it (unsafeIO tricks also). It is hard to get it from GHC, Hugs or others.