Refactoring Chapter 7 and TemplateTypeChecker.ml