Lecture 8: Monads and I/O

15 October 2010

Leading on from the slides by Peyton Jones, this lecture sets out how constructor classes and higher-order functions can help to treat effectful computation within a pure functional language; or potentially contain its influence within an imperative one.

Read the rest of this entry »


Lecture 7: Polymorphism from Types to Kinds and Beyond

12 October 2010

Continuing with types, and in particular some uses in the experimental language laboratory that is Haskell. This lecture covers more on polymorphism, in both object-oriented and functional languages.

Read the rest of this entry »


Lecture 6: Types, Classes, Haskell

8 October 2010

The three lectures today and next week are arranged around some features of the Haskell type system. They aren’t just specific to Haskell, though: several appear in other languages too, and they all address general programming issues. Haskell does make a good setting to examine them, as the language development has had a strong connection to programming language research, and it is sufficiently popular that there is a wide array of commentary out there on how well that works for users.

This lecture covered some background on type systems in programming languages and the different things languages do with them.
Read the rest of this entry »


Lecture 8: Multiparameter Type Classes, Constructor Classes

4 February 2010

More (much, much more) on what you can do with type classes in Haskell: bulk operations on homogeneous collections; subclassing, subclass hierarchy, diamonds; nested class inference; code inheritance, multiway inheritance; multimethods; numeric overloading; arbitrary aspect-like separation of class, type and instance declarations.

The title topics of the lecture: multiparameter type classes (like Collects s e) and constructor classes (like Functor f). Both of these are language extensions, but well-supported and widely used.

Brief mention of yet more language extensions: explicit kinds; higher-rank polymorphism; existential types; and Generalized Algebraic Datatypes (GADTs).

All of these support the thesis of the week: type systems are not just about constraining the user to write safe programs — a well-built type system provides the scaffolding to safely build language features higher and further.

Link: Slides

Homework

Read the following paper on multiparameter type classes.

The final slides from the lecture contain a number of additional references.


Lecture 7: Haskell, Types and Classes

1 February 2010

This block of four lectures are arranged around some features of the Haskell type system. They aren’t just specific to Haskell, though: several appear in other languages too, and they all address general programming issues. Haskell does make a convenient setting to examine them, as the language development has a strong connection to programming language research, and it is sufficiently popular that there is a wide array of commentary out in the blogosphere on how well that works out.

The lecture covered background on type systems in programming languages, what they are used for and how they might be tricky. The interaction of types, subtypes and inheritance in object-oriented languages is an example of this, which Java’s covariant subtyping of arrays conveniently demonstrates. Haskell’s type classes tackle many of the same issues, but from a substantially different direction. Arising originally from attempts to rationalise overloading of basic operations like equality, type classes have grown far beyond this to serve as a tool for imaginatively building a range of high-level programming abstractions.

The presentation itself was somewhat distorted by the non-operation of the projector screen. My apologies, I’ll report it and see if things go better on Thursday.

Link: Slides

Reading

For Thursday’s lecture, read the following paper and set of slides.

For further reading, see the lecture slides. These carry a range of embedded hyperlinks to references, research papers, and background material on the various examples.

Exercise

In the spirit of the diagram from Cook’s paper, can anyone identify a pair of classes A and B, in any OO language or library, where A is (or should be) a subtype of B, while B inherits (or ought to, for code reuse) from A?