a macro for simple pattern matching functions