Type checking for lambdas