Hi Chris,
Good question.
There indeed needs to be some sort of interception of compilation, the typed REPL
and require/load monkey patching alluded to in the talk being examples of that.
Here's what happens in the typed REPL.
1. Pipe unevaluated form through tools.analyzer to get an AST
2. Run AST through type checker, which outputs another possibly-different AST
3. Convert the new AST back to a Clojure form and evaluate with clojure.core/eval.
The interception happens in step 2. One nice property is that the runtime semantics
don't depend on the transformations made by the type checker. In other words, modulo
contract errors and a few other gradual-typing related subtleties, a typed form can also
be directly compiled with any Clojure compiler and still get the same results.
Thanks,
Ambrose