Yes, this is a decent semantic model of how programs are executed. Of course, the implementation does not work, but you can still use this model to parse programs.
But overall, what IO does is allow you to view imperative programs as pure values. Monad operations then allow you to compose imperative programs from small imperative programs (or use the usual term in this context, actions) and pure functions. Thus, a purely functional model, although it cannot execute imperative programs, can still describe them as expressions like IO a , and the compiler can translate these descriptions into imperative code.
Or you could say the following:
- The compiler (and not the runtime) evaluates
main . - The result of this assessment is a mandatory program.
- This program is saved in the target executable file.
- Then you execute the target program.
Ie "Evaluate the main " part of your model is pushed to the compiler and is not in the runtime when you first describe it.
Luis casillas
source share