15-150: Principles of Functional Programming

Lecture 9: Polymorphism and Type Inference

We discussed polymorphic datatypes, such as SML's built in lists as well as a user-defined polymorphic tree type.
We wrote several polymorphic functions, including  trav : 'a tree -> 'a list  and  zip : 'a list * 'b list -> ('a * 'b) list.

We discussed the polymorphic 'a option datatype and wrote a polymorphic lookup function.

We discussed how SML infers types of values, including functions.

Key Concepts

Sample Code

Type checking, Polymorphism, and Type Inference

Structural Induction revisited for polymorphic lists and trees

(today's lecture was a blackboard lecture, so no slides)