Except that it *is* a function value.Entering tutorial mode here... On Thu, 2011-12-29 at 10:04 -0800, Donn Cave wrote:We can talk endlessly about what your external/execution results might be for some IO action, but at the formulaic level of a Haskell program it's a simple function value, e.g., IO Int.Not to nitpick, but I'm unsure what you might mean by "function value" there. An (IO Int) is not a function value: there is no function involved at all. I think the word function is causing some confusion, so I'll avoid calling things functions when they aren't.
Prelude> :type JustThe IO monad is a black box - we can't see the data constructors - but in principle it's the same thing.
Just :: a -> Maybe a
Prelude>
The semantics of the execution of primitive IO actions are part of the Haskell language. The execution isn't pure functional. At compile-time there is no means to evaluate the key functions at all - no way to extract the result out of an IO action because the action cannot be executed and so doesn't (yet) have a result. At run-time, that restriction is removed, or the special evaluation rules are added in - either claim is fine but the effect that Haskell is doing something it couldn't do at compile-time.These are PURE values... they do NOT have side effects. Perhaps they "describe" side effects in a sense, but that's a matter of how you interpret them; it doesn't change the fact that they play the role of ordinary values in Haskell. There are no special evaluation rules for them.