Yet Another Monad Tutorial
Tue, 12 Aug 2003 15:04:39 -0400
Peter G. Hancock wrote:
>>>>>>Jeff Newbern wrote (on Tue, 12 Aug 2003 at 17:20):
> > The functions exported from the IO module do not
> > perform I/O themselves. They return I/O actions, which describe an I/O
> > operation to be performed. The I/O actions are combined within the IO
> > monad (in a purely functional manner) to create more complex I/O
> > actions, resulting in the final I/O action that is the main value of the
> > program. The result of the Haskell compiler is an executable function
> > incorporating the main I/O action. Executing the program "applies" this
> > ultimate I/O action to the outside world to produce a new state of the
> > world.
> That seems to me the wrong thing to say. There is no application. Whether
> or not the word is put in quotes, it is something involving a function
> and an argument. An IO action is not a function.
So then, in your view, what *is* an IO action?
One conceptual model is that an IO action with type (IO a) denotes a
function of type World -> (World,a). Given that model, "applying" an IO
action to the external world seems like a perfectly reasonable account
of executing such an action.
Grad. Student, Dept. of Computer Science, Yale University