partial implementation of compositional type system