Description
BSV allows the user to specify a custom encoding for the derived Bits of an enum. For example, from bsc.bluetcl/commands/Test.bsv in the testsuite:
typedef enum { Red2 = 1, Yellow2, Blue2 } BarSet deriving(Bits);
This is handled by pEnumTag in Parser/BSV/CVParser.lhs (where it fills in the fields like cos_tag_encoding). In the BH/Classic parser (Parser/Classic/CParser.hs) the function pDataB just fills in integers starting from zero ([0..]).
It might be worth creating a BH/Classic syntax for specifying a custom encoding. (It could perhaps be an attribute, if that's easier.) This is part of the larger issue that BSV was the only supported syntax for a long time, so there are some things that can be specified in that syntax but not in BH/Classic. See, for example, issue #224. I don't personally have a need for custom encodings in BH/Classic, but I thought it was worth recording the difference in the Issues database. (Should we have an open Issue for listing all of the known differences? or perhaps this a good use for the new Discussions area?)
Implementing the syntax should be simple, so I'm tagging this as a "good first issue", but we'd need to decide on the syntax first.