IA014 Advanced Functional Programming

Lecture V - Type Classes

Lecture dates

31. 3. 2020 [motivation, introduction, compilation - till slide 14]

7. 4. 2020

Reading

Primary papers

P. Wadler, S. Blott: How to make ad-hoc polymorphism less ad  hoc. POPL'89. [PS]

The paper which introduced type classes. Still great place to start with type classes. You will recognize some material from the lecture.

M. Jones: Functional Programming with Overloading and  Higher-Order Polymorphism. AFPT Spring School 1995. [PDF]

Sums  up the qualified types and constructor classes. Very accessible.

Additional material

M. Jones: A theory of qualified types. ESOP’92.

The paper which introduced qualified types.

M. Jones: A system of constructor classes. FPCA’93.

Constructor classes were introduced here.

M. Jones: Type Classes with Functional Dependencies. ESOP'00.

Introduced the correct way of handling multiparameter type classes.

A History of Haskell: Being Lazy With Class. 2007. (Section 6) [PDF]

J. Peterson and M. Jones: Implementing Type Classes. PLDI'93. [PS]

C. Hall, K. Hammond, S. Peyton Jones, P. Wadler: Type classes in Haskell. ESOP'94. [PS]

Corresponding book chapters

Slides

Chyba: Odkazovaný objekt neexistuje nebo nemáte právo jej číst.
https://is.muni.cz/el/fi/jaro2020/IA014/um/05-typeclasses.pdf
Chyba: Odkazovaný objekt neexistuje nebo nemáte právo jej číst.
https://is.muni.cz/el/fi/jaro2020/IA014/um/51711414/lec5.hs
Chyba: Odkazovaný objekt neexistuje nebo nemáte právo jej číst.
https://is.muni.cz/el/fi/jaro2020/IA014/um/51711414/collect.tgz

Video recordings

Note: To be watched in this order

Type Classes - the motivation

Explains the motivation behind type classes, which is the need to implement ad-hoc polymorphism - i.e. overloading.

Type Classes - a short introduction

A (very) short introduction to type classes on the example of the (simplified) type class Num. Explains the syntax, semantics and terminology used.

Type Classes - compilation

Explains how a compiler can translate code using type classes to an equivalent code without type classes.

Explains the concept of subclasses, with a short discussing of Haskell class hierarchy.

(part of) a recorded lecture from 2019

Covers the rest of Lecture V - from slide 17 (Numeric literals) onward.