This is a minimalistic OCaml implementation of the type system from chapter 30 of TAPL, "Higher-Order Polymorphism".
The implementation uses bidirectional typing and does not feature existential types. Binders are represented as metalanguage functions (HOAS-style), whereas free variables (TyFreeVar and FreeVar in the code) are represented as De Bruijn levels indicating a distance from the root.
See also: