Use type class to generalize RingExpr traversal.