Version: 4.1.5.3
Porting Untyped Modules to Typed Scheme
Sam Tobin-Hochstadt <samth at ccs dot neu dot edu>
To adapt a library to Typed Scheme, the following steps are required:
Determine the data manipulated by the library, and how it will be represented in Typed Scheme.
Specify that data in Typed Scheme, using require-typed-struct and require/opaque-type.
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 scheme/bool library:
| #lang typed-scheme |
| (require/typed scheme/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.