A modular construction of type theories