15-150: Principles of Functional Programming

Lecture 8: 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  inord : 'a tree -> 'a list  and polymorphic insertion sort,  isort : ('a * 'a -> order) * 'a list -> 'a list.

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

Slides from Lecture