15-150: Principles of Functional Programming

Lecture 9: Polymorphism and Type Inference

We discuss polymorphic datatypes, such as SML's built in lists as well as a user-defined polymorphic tree type.
We write a function of type 'a tree -> 'a list.

We discuss the option datatype.

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

We also introduce anonymous functions and continue our exploration of the functions-are-values paradigm.

Key Concepts

Sample Code

Type-checking, Polymorphism, and Type Inference

Structural Induction revisited for polymorphic lists and trees