3 Libraries Provided With Typed Racket

▼ |  | The Typed Racket Reference

1 | Type Reference
2 | Special Form Reference
3 | Libraries Provided With Typed Racket
4 | Typed Classes
5 | Typed Units
6 | Utilities
7 | Exploring Types
8 | Deep, Shallow, and Optional Semantics
9 | Typed Racket Syntax Without Type Checking
10 | Typed Regions
11 | Optimization in Typed Racket
12 | Unsafe Typed Racket operations
13 | Legacy Forms
14 | Compatibility Languages
15 | Experimental Features
| Bibliography
| Index

► | 3 | Libraries Provided With Typed Racket

3.1 | Porting Untyped Modules to Typed Racket

On this page:

3.1`` Porting Untyped Modules to Typed Racket

8.15
top contents ← prev up next →

### 3`` Libraries Provided With Typed Racket🔗ℹ

The typed/racket language corresponds to the racket language—that is, any identifier provided by racket, such as modulo, is available by default in typed/racket.

> #lang typed/racket
> (modulo 12 2)

The typed/racket/base language corresponds to the racket/base language.

Some libraries have counterparts in the typed collection, which provide the same exports as the untyped versions. Such libraries include srfi/14, net/url, and many others.

> #lang typed/racket
> (require typed/srfi/14)
> (char-set= (string->char-set "hello")
> (string->char-set "olleh"))

Other libraries can be used with Typed Racket via require/typed.

> #lang typed/racket
> (require/typed version/check
> [check-version (-> (U Symbol (Listof Any)))])
> (check-version)

The following libraries are included with Typed Racket in the typed collection:

(require typed/file/gif) | package: typed-racket-more

> type GIF-Stream

Describe a GIF stream, as produced by gif-start and accepted by the other functions from file/gif.

> type GIF-Colormap

Type alias for a list of three-element (R,G,B) vectors representing an image.

(require typed/file/md5) | package: typed-racket-lib

(require typed/file/sha1) | package: typed-racket-lib

(require typed/file/tar) | package: typed-racket-lib

(require typed/framework) | package: typed-racket-more

(require typed/json) | package: typed-racket-more

Unlike the untyped json library, typed/json always uses 'null to represent the JSON “null” value. The functions exported by typed/json do not accept a #:null argument, and they are not sensitive to the current value of the json-null parameter. The json-null binding itself is not exported by typed/json.

> type JSExpr

Describes a jsexpr, where 'null is always used to represent the JSON “null” value.

(require typed/mred/mred) | package: typed-racket-more

(require typed/net/base64) | package: typed-racket-more

(require typed/net/cgi) | package: typed-racket-more

(require typed/net/cookies) | package: typed-racket-more

(require typed/net/cookies/common)
| package: typed-racket-more

Added in version 1.10 of package typed-racket-lib.

(require typed/net/cookies/server)
| package: typed-racket-more

> type Cookie

Describes a server-side RFC 6265 HTTP cookie, as implemented by net/cookies/server.

Added in version 1.10 of package typed-racket-lib.

(require typed/net/cookie) | package: typed-racket-more

> NOTE: This library is deprecated; use typed/net/cookies, instead. This library is deprecated for the same reasons that net/cookie is deprecated.

> type Cookie

Describes an HTTP cookie as implemented by net/cookie, which is deprecated in favor of net/cookies.

(require typed/net/dns) | package: typed-racket-more

(require typed/net/ftp) | package: typed-racket-more

> type FTP-Connection

Describes an open FTP connection.

(require typed/net/gifwrite) | package: typed-racket-more

(require typed/net/git-checkout)
| package: typed-racket-more

(require typed/net/head) | package: typed-racket-more

(require typed/net/http-client) | package: typed-racket-more

> type HTTP-Connection

Describes an HTTP connection, corresponding to http-conn?.

(require typed/net/imap) | package: typed-racket-more

> type IMAP-Connection

Describes an IMAP connection.

(require typed/net/mime) | package: typed-racket-more

(require typed/net/nntp) | package: typed-racket-more

(require typed/net/pop3) | package: typed-racket-more

(require typed/net/qp) | package: typed-racket-more

(require typed/net/sendmail) | package: typed-racket-more

(require typed/net/sendurl) | package: typed-racket-more

(require typed/net/smtp) | package: typed-racket-more

(require typed/net/uri-codec) | package: typed-racket-more

(require typed/net/url-connect) | package: typed-racket-more

(require typed/net/url-structs) | package: typed-racket-more

> type Path/Param

Describes the path/param struct from net/url-structs.

> type URL

Describes an url struct from net/url-structs.

(require typed/net/url) | package: typed-racket-more

In addition to defining the following types, this module also provides the HTTP-Connection type defined by typed/net/http-client, and the URL and Path/Param types from typed/net/url-structs.

> type URL-Exception

Describes exceptions raised by URL-related functions; corresponds to url-exception?.

> type PortT

Describes the functions head-pure-port, delete-pure-port, get-impure-port, head-impure-port, and delete-impure-port.

> type PortT/Bytes

Like PortT, but describes the functions that make POST and PUT requests, which require an additional byte-string argument for POST or PUT data.

(require typed/openssl) | package: typed-racket-more

> type SSL-Protocol

Describes an SSL protocol, is an alias for (U 'auto 'sslv2-or-v3 'sslv2 'sslv3 'tls 'tls11 'tls12).

> type SSL-Server-Context
> type SSL-Client-Context

Describes an OpenSSL server or client context.

> type SSL-Context

Supertype of OpenSSL server and client contexts.

> type SSL-Listener

Describes an SSL listener, as produced by ssl-listen.

> type SSL-Verify-Source

Describes a verification source usable by ssl-load-verify-source! and the ssl-default-verify-sources parameter.

(require typed/openssl/md5) | package: typed-racket-more

(require typed/openssl/sha1) | package: typed-racket-more

(require typed/racket/async-channel)
| package: typed-racket-more

Added in version 1.1 of package typed-racket-lib.

(require typed/racket/date) | package: typed-racket-lib

(require typed/racket/draw) | package: typed-racket-more

> type LoadFileKind

Is an alias for (U 'unknown 'unknown/mask 'unknown/alpha 'gif 'gif/mask 'gif/alpha 'jpeg 'jpeg/alpha 'png 'png/mask 'png/alpha 'xbm 'xbm/alpha 'xpm 'xpm/alpha 'bmp 'bmp/alpha).

(require typed/racket/extflonum)
| package: typed-racket-more

> syntax (for/extflvector type-ann-maybe (for-clause ...) expr ...+)
> syntax (for*/extflvector type-ann-maybe (for-clause ...) expr ...+)

(require typed/racket/flonum) | package: typed-racket-more

> syntax (for/flvector maybe-length (for-clause ...) expr ...+)
> syntax (for*/flvector maybe-length (for-clause ...) expr ...+)

(require typed/racket/gui) | package: typed-racket-more

> type Edit-Op

Is an alias for (U 'undo 'redo 'clear 'cut 'copy 'paste 'kill 'select-all 'insert-text-box 'insert-pasteboard-box 'insert-image).

> type Read/Write-Format

Is an alias for (U 'standard 'text 'text-force-cr).

> type File-Format

Is an alias for (U 'guess 'same 'copy Read/Write-Format).

> type Threshold

Is an alias for (U 'no-caret 'show-inactive-caret 'show-caret).

> type Draw-Caret

Is an alias for (U Threshold (Pairof Natural Natural)).

(require typed/racket/gui/no-check)
| package: typed-racket-more

(require typed/racket/random) | package: typed-racket-more

Added in version 1.5 of package typed-racket-lib.

(require typed/racket/sandbox) | package: typed-racket-more

(require typed/racket/snip) | package: typed-racket-more

> type Image-Kind

Is an alias for (U 'unknown 'unknown/mask 'unknown/alpha 'gif 'gif/mask 'gif/alpha 'jpeg 'png 'png/mask 'png/alpha 'xbm 'xpm 'bmp 'pict).

(require typed/racket/system) | package: typed-racket-lib

(require typed/rackunit/docs-complete)
| package: rackunit-typed

(require typed/rackunit/gui) | package: rackunit-typed

(require typed/rackunit/text-ui) | package: rackunit-typed

(require typed/rackunit) | package: rackunit-typed

(require typed/srfi/14) | package: typed-racket-more

> type Char-Set

Describes a character set usable by the srfi/14 functions.

> type Cursor

Describes a cursor for iterating over character sets.

(require typed/srfi/19) | package: typed-racket-more

> type Time
> type Date

Describes an SRFI 19 time or date structure.

(require typed/syntax/stx) | package: typed-racket-more

(require typed/web-server/configuration/responders)
| package: typed-racket-more

(require typed/web-server/http) | package: typed-racket-more

Changed in version 1.10 of package typed-racket-lib: Updated to reflect web-server/http version 1.3.
Changed in version 1.11: Updated to reflect web-server/http version 1.4.
Changed in version 1.13: Updated to reflect web-server/http version 1.6.

(require typed/db) | package: typed-racket-more

(require typed/db/base) | package: typed-racket-more

(require typed/db/sqlite3) | package: typed-racket-more

In some cases, these typed adapters may not contain all of exports of the original module, or their types may be more limited.

Other libraries included in the main distribution that are either written in Typed Racket or have adapter modules that are typed:

(require math) | package: math-lib

(require plot) | package: plot-gui-lib

(require typed/pict) | package: typed-racket-more

(require images/flomap) | package: images-lib

(require typed/images/logos) | package: typed-racket-more

(require typed/images/icons) | package: typed-racket-more

(require typed/images/compile-time)
| package: typed-racket-more

#### 3.1`` Porting Untyped Modules to Typed Racket🔗ℹ

To adapt a Racket library not included with 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/or #:struct.

- Use the data types to import the various functions and constants of the library.

- Provide all the relevant identifiers from the new adapter module.

For example, the following module adapts the untyped 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.

top contents ← prev up next →