Yet Another Monad Tutorial

Bayley, Alistair Alistair_Bayley@ldn.invesco.com
Tue, 12 Aug 2003 12:10:24 +0100


> From: Wolfgang Jeltsch [mailto:wolfgang@jeltsch.net]
> 
> For example, the function readFile is pure. For a specific 
> string s the 
> expression readFile s always yields the same result: an I/O 
> action which 
> searches for a file named s, reads its content and takes this 
> content as the 
> result of the *action* (not the expression).

What about getChar? This is a function which takes no arguments, yet returns
a (potentially) different value each time. I know, I know: it returns an IO
action which reads a single char from the terminal and returns it.

Is the IO monad the only one (currently) in which you would say that it
"returns an action", which is then executed by the runtime system? I would
have thought that monads that are not involved in IO (e.g. State) would be
pure in the sense that Van Roy was thinking. You wouldn't need to describe
functions in them as "returning an action".


*****************************************************************
The information in this email and in any attachments is 
confidential and intended solely for the attention and use 
of the named addressee(s). This information may be 
subject to legal professional or other privilege or may 
otherwise be protected by work product immunity or other 
legal rules.  It must not be disclosed to any person without 
our authority.

If you are not the intended recipient, or a person 
responsible for delivering it to the intended recipient, you 
are not authorised to and must not disclose, copy, 
distribute, or retain this message or any part of it.
*****************************************************************