generalized type checking in patterns