Work in progress on the type soundness.

Putting the module environment in closures complicates thing more than I
anticipated, because the typing relation for values now has to be in mutual
recursion with the typing relation for modules.