Number and Complex are synonyms. This is the most general
numeric type, including all Racket numbers, both exact and inexact, including
complex numbers.
Includes Racket’s exact integers and corresponds to the
exact-integer? predicate. This is the most general type that is still
valid for indexing and other operations that require integral values.
Includes Racket’s double-precision (default) floating-point numbers and
corresponds to the flonum? predicate. This type excludes
single-precision floating-point numbers.
Includes Racket’s single-precision floating-point numbers and corresponds to
the single-flonum? predicate. This type excludes double-precision
floating-point numbers.
Includes all of Racket’s real numbers, which include both exact rationals and
all floating-point numbers. This is the most general type for which comparisons
(e.g. <) are defined.
These types correspond to Racket’s complex numbers.
The above types can be subdivided into more precise types if you want to
enforce tighter constraints. Typed Racket provides types for the positive,
negative, non-negative and non-positive subsets of the above types (where
applicable).
Natural and Exact-Nonnegative-Integer are synonyms. So are
the integer and exact-integer types, and the float and flonum
types. Zero includes only the integer 0. Real-Zero
includes exact 0 and all the floating-point zeroes.
These types are useful when enforcing that values have a specific
sign. However, programs using them may require additional dynamic checks when
the type-checker cannot guarantee that the sign constraints will be respected.
In addition to being divided by sign, integers are further subdivided into
range-bounded types.
One includes only the integer 1. Byte includes
numbers from 0 to 255. Index is bounded by
0 and by the length of the longest possible Racket
vector. Fixnum includes all numbers represented by Racket as machine
integers. For the latter two families, the sets of values included in the types
are architecture-dependent, but typechecking is architecture-independent.
These types are useful to enforce bounds on numeric values, but given the
limited amount of closure properties these types offer, dynamic checks may be
needed to check the desired bounds at runtime.
The union of the Path and
String types. Note that this does not
match exactly what the predicate path-string?
recognizes. For example, strings
that contain the character #\nul have the type
Path-String but path-string? returns
#f for those strings. For a complete specification
of which strings path-string? accepts, see its
documentation.
1.2Singleton Types
Some kinds of data are given singleton types by default. In
particular, booleans, symbols, and keywords have types which
consist only of the particular boolean, symbol, or keyword. These types are
subtypes of Boolean, Symbol and Keyword, respectively.
Examples:
> #t
- : Boolean [generalized from True]
#t
> '#:foo
- : #:foo
'#:foo
> 'bar
- : Symbol [generalized from 'bar]
'bar
1.3Containers
The following base types are parameteric in their type arguments.
is the type of a list with
one element for each of the ts, plus a sequence of elements
corresponding to trest, where bound
must be an identifier denoting a type variable bound with ....
The following types represent prompt tags and
keys for continuation marks for use with delimited continuation
functions and continuation mark functions.
A continuation mark key that is used for continuation mark
operations such as with-continuation-mark and
continuation-mark-set->list. The type t
represents the type of the data that is stored in the
continuation mark with this key.
is the type of functions from the (possibly-empty)
sequence dom... to the rng type. The second form
specifies a uniform rest argument of type rest, and the
third form specifies a non-uniform rest argument of type
rest with bound bound. In the third form, the
second occurrence of ... is literal, and bound
must be an identifier denoting a type variable. In the fourth form,
there must be only one dom and pred is the type
checked by the predicate. dom can include both mandatory and
optional keyword arguments.
is a function that behaves like all of
the fun-tys, considered in order from first to last. The fun-tys must all be function
types constructed with ->.
is a parameterization of type t, with
type variables v.... If t is a function type
constructed with ->, the outer pair of parentheses
around the function type may be omitted.
is a type which is a supertype of all instances of the
potentially-polymorphic structure type st. Note that structure
accessors for st will not accept (Structst) as an
argument.