Write Yourself a Scheme in 48 Hours

Write Yourself a Scheme in 48 Hours is a featured book on Wikibooks because it contains substantial content, it is well-formatted, and the Wikibooks community has decided to feature it on the main page or in other places. Please continue to improve it and thanks for the great work so far! You can edit its advertisement template.

This book starts with advanced concepts such as monads, and does not always give a precise, comprehensive and clear treatment of them. If you understand the topics being dealt with, we welcome your improvements and clarifications. There is also a very gentle Haskell tutorial which is under more active development.

Overview

Most Haskell tutorials on the web use a style of teaching akin to language reference manuals. They show you the syntax of the language, a few language constructs, then tell you to create a few simple functions at the interactive prompt. The "hard stuff" of how to write a functioning, useful program is left to the end, or omitted entirely.

This tutorial takes a different approach. You'll start off using and parsing the command-line, then progress to writing a fully-functional Scheme interpreter that implements a decent subset of R5RS Scheme. Along the way, you'll learn Haskell's I/O, mutable state, dynamic typing, error handling, and parsing features. By the time you finish, you should become fairly fluent in Haskell and Scheme.

Users of a procedural or object-oriented language like C, Java, or Python should beware: You'll have to forget most of what you already know about programming. Haskell is completely different from those languages, and requires a different way of thinking about programming. It's best to go into this tutorial with a blank slate; try not to compare Haskell to imperative languages, because many concepts (including classes, functions, and return) have significantly different meanings in Haskell.

Since each lesson builds upon code written in previous ones, it's generally best to go through them in order.

This tutorial assumes that you'll use GHC as your Haskell compiler. The code may work with Hugs or other compilers, but hasn't been officially tested with them, and may require downloading additional libraries.

A prior, non-wiki-edited version of the source code files used in this tutorial is available on the original site[dead link].