Porting Untyped Modules to Typed Racket
Sam Tobin-Hochstadt <samth@ccs.neu.edu>
To adapt a library to Typed Racket, the following steps are required:
Determine the data manipulated by the library, and how it will be represented in Typed Racket.
Specify that data in Typed Racket, using require/typed and opaque and struct.
Use the data types to require the various functions and constants of the library.
Provide all the relevant identifiers from your new adapter module.
For example, here’s a module for adapting the racket/bool library:
#lang typed/racket (require/typed racket/bool [true Boolean] [false Boolean] [symbol=? (Symbol Symbol -> Boolean)] [boolean=? (Boolean Boolean -> Boolean)] [false? (Any -> Boolean)]) (provide true false symbol=? boolean=? false?)
More substantial examples are available in the typed collection. In particular, see the various files in typed/net, such as typed/net/url.ss.