Each typed module now defines a submodule named `type-decl`.
This module performs the type environment initialization (along
with other environment updates) when invoked. Additionall,
every typed module, when invoked, performs a for-syntax addition
to a list specifying the submodules that need invocation.
This invocation is then performed by the `#%module-begin` from
Typed Racket.
The `type-decl` module always goes at the beginning of the
expanded module, so that it's available at syntax-time for all
the other submodules. This involved adding pre- and post-
syntaxes for the results of typechecking.
This allows significant runtime dependency reduction from the
main `typed/racket` and `typed/racket/base` languages (not yet
complete).
Previously, some hacks were used to obtain the internal
identifiers that implemented keyword functions directly, and
give them types at startup. Now, the primary "function"
(eg, `sort`) is given a type, and when used, the residual
syntax properties are used to find `sort` from the real
functions, and then the type of the real function is computed
from the type of `sort`.
Some creativity was required in the types of functions which
take optional arguments that when present, alter the return type,
such as `regexp-match*` and `file->list`.