[OT] Teaching Haskell in High School

Arjan van IJzendoorn afie@cs.uu.nl
Tue, 4 Feb 2003 10:21:03 +0100


John Peterson wrote:

> The downside of Haskell is that none of the regular implementations
> (ghc, hugs) are really right for this level of student.  Type
> inference is an especially nasty problem.  There also a number of
> gotcha's lurking in the language that cause problems.

For exactly these reasons we have implemented Helium; not for replacing
Haskell (we're very happy with Haskell), but for *learning* Haskell. There
is no overloading, so types and type errors are easier to understand. The
Helium compiler produces warnings for situations that are probably
incorrect. I've found myself look at a program with a comparable problem as
the one below for fifteen minutes until I saw what was happening (please
look at the program with a non-proportional font like Courier for optimal
confusion):

filterr :: (a -> Bool) -> [a] -> [a]
filterr p [] = []
fi1terr p (x:xs) = if p x then x : filterr p xs else filterr p xs

Hugs, which we used for teaching, doesn't say a word. GHC does if you
helpful warnings if you pass the -Wall flag. Helium says:

(2,9): Variable "p" is not used
(3,1): Missing type signature: fi1terr :: (a -> Bool) -> [a] -> [a]
(3,1): Suspicious adjacent functions "fi1terr" and "filterr"

I'm curious what the other "gotcha's" are that John refers to because it
might give
us inspiration for more warnings/language design decisions.

Arjan
http://www.cs.uu.nl/~afie/helium/