Every well-formed expression has a precise type. The two basic types in Q are the following:
The types string, integer, real, and Boolean range over the corresponding primitive values; regexp ranges over regular expressions; and object ranges over instances of metaclasses.
In addition to the basic types, the Q language supports the following three forms of constructed types: tuples, collections, and functions.
Although this scheme of type representation accommodates arbitrarily complex types, in practice there are limitations in the current implementation that restrict the complexity. Specifically, the current implementation supports the basic types, tuples of basic types, object collection, string collection, and functions that take and return any of these supported types, except for tuples for return types. There is also special support for the types (object → string) x object collection → string collection (which is the type of the built-in function map), (object → boolean) x object collection → object collection (which is the type of the built-in function filter), and other such types for traverse and sort.
The following are some examples of more complicated types: