Computational complexity via finite types