Your view of IO
is good, but I have a problem with this line
Calls main to get back an "IO computation"
The best way to think about Haskell is that functions dont do anything. Rather, you declaratively describe what values are. A program consists of a description of an IO
value called main
. The only sense to which it "calls main" is that the declaration of main
is reduced to Weak Head Normal Form (or something similar).
IO
is the type of arbitrary side effect-full computations. The pure subset of Haskell is a purely declarative description of values, that happens to allow for undecidable descriptions. Think of Haskell as a mathematical language like set theory. Statements in set theory dont do anything, but they might involve complicated computations like "the smallest set which contains Akerman's_function(30)". They can also contain undecidable statements like "S = the set of all sets that do not contain themselves"
@amindfv is half right: main
is not a "pure function". It is not a function at all. It is a value, defined by a pure reduction, encoding unpure computation.