[Haskell-cafe] Composing functions with runST

C.M.Brown cmb21 at kent.ac.uk
Wed Jan 3 14:29:31 EST 2007


> It's true that this is the typical way of learning Haskell, but I for
> one think it's a bad way of learning Haskell.
> Very few real world programs get by without the "impure" stuff, so if
> you give the newbie the impression that it isn't there (by postponing
> it) there's a chance he'll run into a situation where he needs it
> before it's been even mentioned (queue newbie going "bah, academic
> language" and switching to C++).

I agree. It also confuses matters when the newbie is suddenly given a
library of IO code to use -- but told to ignore it -- they suddenly start
wondering why it is so difficult to do anything "useful" in Haskell. A
consequence of which seems that the student becomes afraid (and ignorant)
of Haskell.

> I find that the Haskell introductions I like the most are the ones
> that accompany papers about STM and such. I.e. ones which have to
> teach the reader about the basics of Haskell IO, but doesn't have
> enough space to start with the pretty stuff.

I agree with this also. I don't think it is a difficult feat teaching an
absolute beginner how do some some basic stuff with the IO monad. This
shows straight away that haskell can do some useful stuff other than
adding numbers together in Hugs.

>Mix that with some actual
> comutations to show off some pretty stuff and you'll have a newbie who
> is both excited about the cool looking features of the pure aspects of
> Haskell, but completely aware of the fact that you can do impure stuff
> as well.

Yes, I wish this approach was applied much more often. Semi-related to
this: I taught an algorithms and data structures class last term. In one
of the classes the students were given an equation to solve and they were
frantically typing it into their calculators, replacing the variable
parameters with numbers. I told them they could all finish the class in 5 minutes if they
used Haskell. Type the equation as it is and use higher-order functions to
work out the parameters. The look of horror on the student's faces when I
mentioned the 'H' word was priceless. However, they were all prepared to
spend 50 minutes writing a Java program which would have the same effect.


More information about the Haskell-Cafe mailing list