Wrap the pattern into a trait to unify the types