Type pattern matching code