Haskell's syntax

Arjan van IJzendoorn afie@cs.uu.nl
Tue, 22 Apr 2003 15:19:48 +0200


Hello everyone,

I teach Haskell to our first-year students and I find that Haskell's syntax
is confusing to many. Some examples:

(1) You define data types with vertical bars (|) but in the world of
expressions vertical bars (i.e. guards) are exactly what you can not use to
discriminate between constructors.

(2) Pattern-matching and guards are very often mixed up. Both are used for
making choices and they overlap somewhat but not completely in expression
power. For learning a language it would be nice if one construct did it all,
guards including pattern guards maybe.

(3) Types and expressions look very much alike. Say we have:
  data Tree a = Bin (Tree a) a (Tree a) | Nil.
Around half (!) of the students now write (on a written test):
  size (Bin (Tree left) x (Tree right)) = ...
mixing up the two worlds completely.

Do other teachers have the same experience?

Regards, Arjan