Add typematch() function to make type-based decisions