Automatic construction of CHOICE types in ruby