Typed Scheme: A Brief Introduction for PLT Scheme Programmers

Sam Tobin-Hochstadt

March 16, 2007

Typed Scheme is a Scheme-like language, with a type system that supports common Scheme programming idioms. Explicit type declarations are required — that is, there is no type inference. The language supports a number of features from previous work on type systems that make it easier to type Scheme programs, as well as a novel idea dubbed “occurrence typing” for case discrimination.

Typed Scheme is also designed to integrate with the rest of your PLT Scheme system. It is possible to convert a single module to Typed Scheme, while leaving the rest of the program unchanged. The typed module is protected from the untyped code base via automatically-synthesized contracts.

Further information on Typed Scheme is available from http://www.ccs.neu.edu/home/samth/typed-scheme.html .

Installation

There is no need to specifically install Typed Scheme. Simply running one of the example programs described in this manual will automatically download and install the necessary software. However, it can also be installed from the MzScheme or DrScheme prompt with the following require statement:

(require (planet "info.ss" ("plt" "typed-scheme.plt")))

In order to use the Typed Scheme language level in DrScheme, DrScheme must be restarted after installation.

 

Contents

    1  Starting with Typed Scheme
        1.1  A First Function
        1.2  Adding more complexity
        1.3  Defining New Datatypes
        1.4  Recursive Datatypes and Unions
        1.5  Giving Names to Types

    2  Polymorphism

    3  More Built-In Types

    4  Special Form Reference
        4.1  Binding Forms
        4.2  Structure Defintions
        4.3  Type Aliases
        4.4  Type Annotation
        4.5  Require

    5  The Typed Scheme Language Level

Last modified: Wednesday, December 20th, 2006 11:30:51am