So You've Always Wanted to Learn Haskell?

Instructors: Jean Q. Yang and Joe P. Near
{jeanyang, jnear}@csail.mit.edu

 

Lecture 1 slides

Haskell is a statically-typed, purely functional programming language similar to ML (think Scheme with strong types and type inference--and without the parentheses). If you've always wanted to learn Haskell but didn't know how to start or haven't gotten around to it, this is the class to overcome the activation barrier. We will describe how Haskell works, show you how to compile and run your first programs, and give you an idea of programs Haskell is good for writing.

Your Haskell education should proceed as follows:

  1. Haskell basics. At the core, Haskell is a functional language with a strong, static type system. If you are familiar with functional programming, the only thing to get used to is the type system (which supports bounded parametric polymorphism) and the type inference engine, which can infer polymorphic types.
  2. Monads. In a pure functional language (one without any effects), a good design pattern for storing state is by carrying it around as an extra argument representing the world. Monads in Haskell are just a language construct supporting the manipulation of this world. Haskell supports doing all kinds of effectful things this way, including I/O.
  3. Type classes. Most language support overloading in an ad hoc way. Haskell supports overloading with type classes, which define classes of types that support a given set of operations. For instance, the Show class comprises types a that define the show : a -> string function for serializing a value of type a.
  4. Advanced topics. This is beyond the scope of the class, but there are all kinds of fancy things in Haskell having to do with types (phantom types, arrows) and pure functional programming (functional reactional programming, etc.) you can pursue.


Prerequisites

We expect people to be familiar with functional programming idioms (higher-order functions and partial application, map/reduce) and have experience programming in languages with static type systems (C/Java is fine).


Administrivia

The course will take place 3-5PM January 25-26, 2010 (Monday and Tuesday), 34-301. There will be no homework, but we recommend doing some preparation before classes to get the most out of lecture.


Course Outline:

Day 1: Getting started with Haskell. Jean will talk about the logistics of using Haskell (GHC compiler/GHC interactive shell), the principles of Haskell (static typing, algebraic data types, living in a purely functional world), and work up to explaining monads as a built-in language construct for threading state through a functional computation. Recommended preparation:

Day 2: Uses for Haskell. Joe will go through some programs written in Haskell to highlight 1) how Haskell looks in the wild and 2) the strengths of Haskell as a programming tool. Recommended preparation:


Compiling and running Haskell

The typical use of Haskell involves compiling it and running the binaries. We recommend using the Glasgow Haskell Compiler (GHC). There is also an interactive shell GHCi that is useful for loading programs to check the types of things, etc.


Resources


Why Haskell?