Type checking of patterns