How to teach Haskell

The authors of Real World Haskell just posted the first drafts for reviewers, including me. Much of the book is spent trying to explain simple concepts, while addressing the subtleties that result from Haskell’s shorthands and abstracctions. Something occurred to me as I was reading: the easiest way to learn Haskell is to learn some Lisp.

But not traditional Lisp. This Lisp is lazy, has nothing but symbols, lists, and tuples, and enforces the type differences among them. There is a let form but no define, certainly no setq. It’s lambdas are curryable. The whole realm can be explored, its lessons learned, in a couple of days.

It’s a useless language, except for its purpose. It is Limbo to Haskell’s Inferno — not Haskell itself, but sitting on the edge, where the virtuous of the past go who did not survive to the monadic revolution…

After developing the patterns of lists and lambda calculus, and the basic habits of strong typing, in this realm, the first descent into Haskell is fast. In ten minutes, you discuss the slightly changed notation, point out that we have entirely hidden the underlying cons structure of the list, and arrive at the type system.

Now the type system is an obvious extension of a habit to handle this new, more complicated world. The first unexpected structure is the algebraic data type, a transformation of a piece of BNF. I think this is the only place in computer science where the BNF is the clearest way to teach something.

Then there’s a bumpy half an hour about the syntax for defining functions, a period of clarity in general but confusion in detail about type classes, and then you arrive at

MONADS

And I don’t know how to make this one easy. sigfpe has made the beginning clear, but the rest is still obscure.

On the other hand, if a newcomer picked up a book on Haskell and was told that they were going to spend two chapters learning a dialect of Lisp they would never use again, it might not sell well.

2 Comments

  1. Gawain:

    i was floored to see anyone else blog about Haskell — until I noticed that your Haskell and mine are not the same… :(

  2. madhadron:

    The name’s taken from Curry Haskell, a logician. Which Haskell occurred to you? I’d love to know.

Leave a comment