Biggest Haskell unit in the world

Richard Watson
Thu, 28 Jun 2001 15:39:10 +1000 (EST)

On Wed, 27 Jun 2001, Hamilton Richards wrote:

> At 7:57 PM -0500 6/25/01, you wrote:
> >
> >BTW I teach a "programming languages" course which includes an
> >introduction to Haskell and an introduction to parsing and compiling.
> >The students modify an interpreter that I wrote.  The complete Haskell
> >source for the language (simple block structured imperative language
> >with a single integer daya type) is only 600 lines, of which about half
> >is the parser. This compares favourably with a similar toy compiler in
> >C++ that was used before I took over the course --- it ran to well over
> >5000 lines!
> That's very interesting to me, since I, too, teach a programming languages
> course which includes an intro to Haskell and to parsing. An interpreter
> for an imperative language would pull a lot of topics nicely together.

That was my motivation in developing the interpreter. I think it has
worked pretty well. Although a toy it is "real" enough to provide
a genuine intro to language implementation issues like parsing,
symbol table maintenance, semantic checks, run time stack etc.
> Do your students know any Haskell coming into the course, or is your
> introduction to Haskell their first taste of it?

This is their first taste of Haskell. Some love it and some never
become comfortable with it.

> Does the imperative language include procedures? With what methods of
> binding arguments to parameters? What sort of modifications can the
> students manage?

The language is modelled on Pascal: it uses the same scoping rules as
Pascal and supports nested procedure declarations. Apart from minor syntactic
differences (like { } not begin ... end) the main differences are
- single integer data type
- no functions 
- parameter passing is call by value
- all operators (usual relational & arithmentic) have same precedence
- if and while are only control structures
- io is limited to reading and writing a single integer at a time

So far over the past few years I've set questions such as adding
- unary operators
- parenthesised expressions
- a C-like ternary ? : expression
- Haskell-like comments
- for statements
- repeat .. until post test loops
- constant declarations
- functions
- call by reference parameters
- call by value-result parameters

The last 4 have been the most challenging but good average students
have generally succeeded in completing such questions.

Dr Richard Watson             
Dept of Mathematics & Computing         phone: +61 7 4631 5546
University of Southern Queensland       FAX:   +61 7 4631 5555 
Toowoomba Qld 4350, AUSTRALIA