Implement type checker.