3 ms·
You can build a completely pure version of the IO type assuming Haskell's evaluation semantics, so long as you have one base "escape" function ffi : String -> S
by rtpg 12y ago
You can build a completely pure version of the IO type assuming Haskell's evaluation semantics, so long as you have one base "escape" function ffi : String -> String (or whatever serialization you want) that serves as a foreign function interface. Mind yo, the ffi function is evaluated the same way (with all the non-strictness involved) as other functions in Haskell.
There's no such thing as inpure Haskell, even in your IO monad (this is more theory than fact with GHC, for performance reasons). Basically your IO type is some instructions for the runtime. The runtime does stuff and then injects values back into Haskell, but for the language itself, values are not changing.
I have a hard time explaining it. But I think GP's point was that you evaluate main to get something of type IO (), and the runtime takes something of type IO () to do stuff with it (much like the difference between javac and java). There's some juggling going along with it...