[Haskell-cafe] IO is a bad example for Monads

Ketil Malde ketil+haskell at ii.uib.no
Mon Dec 10 04:36:55 EST 2007

Daniel Fischer <daniel.is.fischer at web.de> writes:

>> Well, I guess you could get pretty far using 'interact' - far enough
>> in an educational setting to do lists and Maybe, and then monads,
>> before introducing monadic IO.

> Pretty far, yes, and in an educational setting, at a university, it is quite 
> common, I believe, to use an interpreter for a while, not producing 
> executables (that's how I met Haskell, write pure functions and type 
> expressions at the Hugs prompt). But what about a tutorial for programmers?
> How would you do

Well, yes, some things do get complicated, and I'm not suggesting that
"interact" will suffice for real programs.  I still agree with the
faction that thinks monadic IO should be taught after non-IO
monadics - which, especially for programmers, can be quite early in
the curriculum.  After all, lists and algebraic data types are central
and simple concepts.

I don't think you *need* to teach input-print sequential programs,
though.  This is functional programming after all, why not build a
compiler instead? 

> I doubt you could keep many interested without telling them how to create 
> standalone programmes, including reading input from stdin and printing output 
> to stdout.

Well, my first "real", standalone haskell program was reading my
telephone log from stdin, matching against an internal database, and
outputting calls with time and name to stdout.  I used standard
features like shell IO redirection in and 'tee' to integrate with the
rest of the system.

I then moved on to monadic IO, but wish I'd done monads in general
first.  YMMV.

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list