The idiomatic way is with ADT (object variants) like Araq showed, you will find alternative representations in [this repo](https://github.com/mratsim/compute-graph-optim) where I'm writing a ML compiler, note that I'm trying to get a flexible user-extensible representation so idiomatic variants are not enough:
* user-extensible ADTs: [https://github.com/mratsim/compute-graph-optim/blob/master/e07_part2_var_ADTs_grammar.nim#L8-L18](https://github.com/mratsim/compute-graph-optim/blob/master/e07_part2_var_ADTs_grammar.nim#L8-L18) * object algebra (i.e. using generics, the inheritance part is unnecessary): [https://github.com/mratsim/compute-graph-optim/blob/master/e01_obj_algebra.nim](https://github.com/mratsim/compute-graph-optim/blob/master/e01_obj_algebra.nim) * typed tagless final (i.e. using function calls): [https://github.com/mratsim/compute-graph-optim/blob/master/e05_typed_tagless_final.nim#L26-L30](https://github.com/mratsim/compute-graph-optim/blob/master/e05_typed_tagless_final.nim#L26-L30)
