Download this episode
In this second lecture in the series, Ralf digs into Type Classes, which are type system constructs that were originally introduced to provide a form of ad hoc polymorphism (i.e., an advanced form of overloading). Type classes amount to an intriguing element of the Haskell language, which is, for example, evident in their ability to solve the Expression Problem (make sure you watch Ralf's first lecture on this subject). Furthermore, type classes directly relate to the interface notion of mainstream OO programming, adding important expressiveness to C#/Java-like interfaces.
Type classes also take functional or declarative programming to a whole new level—one may define relations and functions pointwisely on types. That is, in the same way a regular function pattern matches on value structure, a type-level function sort of matches
on type-definitional structure. This is quite a mouthful, I know.
There are various extensibility scenarios in the neighborhood of the Expression Problem that are interesting to consider from a design perspective, including several also addressable with type classes, and others that aren't. Look for the riddles (there are indeed several riddles in this lecture); many of them call for a discussion, rather than a straight solution. But beware—some of them are really difficult.
Thank you, Ralf, for another great lecture!
Get the slides for this lecture.
See Lecture 1 - The Expression Problem
Available formats for this video:
Actual format may change based on video formats available and browser capability.