Encode the grouping rules in the types