Reduce redundancy with a type class