More Built-In Types
Typed Scheme comes with a number of other types and type constructors, corresponding (mostly) to primitive types provided by PLT Scheme.
The base types represent primitive data
number
Any numberstr
A stringsymbol
A symbolboolean
Either#t
or#f
keyword
A PLT Scheme literal keywordtop
Any value
The following constructors are parameteric in a single type argument
(Listof t)
Homogenous lists oft
(Vectorof t)
Homogenous vectors oft
(Option t)
Eithert
or#f
(cons s t)
is the pair containings
as thecar
andt
as thecdr
(dom ... -> rng)
is the type of functions from the (possibly-empty) sequencedom ...
to therng
type.(dom ... rst .. -> rng)
is the type of functions from the (possibly-empty) sequencedom ...
with an optional trailing sequence ofrst
to therng
type. Note:..
is a part of the syntax of these types.(U t ...)
is the union of the typest ...
(case-lambda fun-ty ...)
is a function that behaves like all of thefun-ty
s. Thefun-ty
s must all be function types constructed with->
.(t t1 t2 ...)
is the instantiation of the parametric typet
at typest1 t2 ...
(pred t)
is a predicate for typet
(All (v ...) t)
is a parameterization of typet
, with type variablesv ...
(values t ...)
is the type of a sequence of multiple values, with typest ...
. This can only appear as the return type of a function.v
wherev
is a number, boolean or string, is the singleton type containing only that valuei
wherei
is an identifier can be a reference to a type name or a type variable
Other types cannot be written by the programmer, but are used internally and may appear in error messages.
#<struct:n (t ...)>
is the type of structures namedn
with field typest
. There may be multiple such types with the same printed representation.(mu n t)
is a recursive type wheren
is bound to the recursive type in the bodyt
<n>
is the printed representation of a reference to the type variablen