Generalize 'weight_' to any monoid, change 'weight' and 'label' to lookup representative element