CSE583: Programming Languages

1/18/00


Click here to start


Table of Contents

CSE583: Programming Languages

Functional programming: two weeks

Flash!

Shift: From Scheme to theory

Functions and their combination

The lambda calculus

Function definition

Function application

That it!

Currying

Beta reduction rule

Representation

(Non-negative) integers

Defining addition

Reduction

Representing booleans

Defining cond

Normal form

Reduction order

Example

High-level view

A different high-level view

An aside: call by name

Call by name

Jensen’s device

Comparing reduction orders

Strict functions

More strictness

Fixed-points (or fixpoints)

Example

The good news

But its complicated

In theory, there is no difference between theory and practice

But…

Example

What do to?

Theory

ML

What’s different from Scheme?

Basic datatypes

Lists

List examples

Tuples

Records

Bindings

Local variables for expressions

Named function definitions

Anonymous functions

Function types

Using tuples

Minor notes

Another function type example

Pattern matching: on tuples

Another couple of examples

Pattern matching with functions

Another example

And here is such an example

Polymorphic functions

Polymorphic types

On invocation

Examples

Currying

Exploiting juxtaposition

A pattern-based curried map

Clean syntactic sugar for currying

Reminder: currying is

Polymorphism vs. overloading

How does ML handle overloading?

Equality types

Examples

Type inference: infer types of expressions automatically

Type inference: partial refinement

Properties of ML’s type system

Examples

Next time

Author: David Notkin

Email: notkin@cs.washington.edu

Home Page: http://www.cs.washington.edu/education/courses/583

Download presentation source