code: func (tc *typeChecker) CheckTypes(env *TypeEnv, sorted []util.T) (*TypeEnv, Errors) {
  	if env == nil {
  		env = NewTypeEnv()
  	} else {
  		env = env.wrap()
  	}
  	for _, s := range sorted {
  		tc.checkRule(env, s.(*Rule))
  	}
  	return env, tc.errs
  }
docs: // CheckTypes runs type checking on the rules returns a TypeEnv if no errors
  // are found. The resulting TypeEnv wraps the provided one. The resulting
  // TypeEnv will be able to resolve types of refs that refer to rules.