-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Oct 27, 2008, at 7:25 PM, Rodney D Price wrote:
Perhaps my mental picture is a little less flawed, now, but this brings up something about the IO monad that has always bothered me. Papers on the IO monad say things like "A term of type IO () denotes an action, but does not necessarily perform the action." (Wadler, "How to Declare an Imperative") Or, "putc '!' denotes the command that, if it is ever performed, will print an exclamation mark."
I like to think of the IO monad as a lazy imperative program generator. That is, the runtime lazily evaluates actions as they are needed, perhaps as though main is a (potentially infinite) lazy list of actions. In my mental model, runtime basically works like: What should I do first? *evaluate first action* *perform action* What should I do next? *evaluate next action* *perform action* What should I do next? *evaluate next action* *perform action* What should I do next? *evaluate next action* *perform action* ... - - Jake -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkkGiCoACgkQye5hVyvIUKkBhACgsT4zg5D+FBkLx7+qBu4xcWvF gYwAnR+wrDdipCHAhJP2cTNcoq54ZklU =OM1+ -----END PGP SIGNATURE-----