Learning Haskell and FP

Jan Skibinski jans@numeric-quest.com
Fri, 5 Jan 2001 07:36:23 -0500 (EST)

On Fri, 5 Jan 2001, Michael Zawrotny wrote:

>I would love to see something that is more about getting
> things done in a how-to sense, including IO.  Much of the material I've
> seen tends to either relegate IO and related topics into a small section
> near the end (almost as if it were somehow tainted by not being able
> to be modelled as a mathematical function), or it goes into it talking
> about monads and combinators and things that make no sense to me.

	Aside from variety of excellent theoretical papers on "monads and
	combinators and things" there are at least three or four down to
	earth attepmts to explain IO in simple terms. Check Haskell Wiki
	page for references. 

	Personally, I like the "envelope" analogy, which is good enough
	for all practical IO manipulations: you open IO envelope,
	manipulate its contents and return the results in another
	envelope. Or you just pass unopened envelope around if you
	do not care reading its contents. But you are not allowed to
	pollute the rest of the program by throwing unwrapped
	"notes" around; they must be always enclosed in IO "envelopes".
	This is an example of a "howto recipe", as you asked for.

	There are plenty of library code and short applications
	around where IO monad is used for simple things, like reading
	and writing to files, communicating with external processes
	(reading a computer clock or something), exchanging information
	with web servers (CGI libraries and similar applications), etc.
	Some do data acquisition (like reading arrays from files)
	some do nothing more but simply write data out, as in my
	GD module. 
	[This is not a self promotion, this is just the simplest possible
	useful IO application that comes to my mind now. Check also
	"funpdf" - there are plenty examples of reading, writing and
	interacting with a purely functional world.]