Stateful typechecker in preparation for unique types.
Start of unification for typechecking.