
2 Jul
2007
2 Jul
'07
5:38 p.m.
Gregory Propf wrote:
Right, I read more about it and found this out. The 'main' function is apparently magical at runtime and allows you to break the with pure functionality just once but since it can call other functions this allows for useful programs to be written.
There is more than one way to look at this, but I wouldn't say purity is broken, not even by the main function. You can think of an IO action as an 'execution plan', containing detailed instructions on obtaining input, applying functions, branching, creating output, etc. The compiler takes the 'main' execution plan, and creates a program that will actually perform it. As a programmer, you only compose execution plans, which is nice and pure. Kind regards, Arie