Support arbitrary enum values at runtime
Because enums are "just ints" in C++, APIs sometimes take advantage of this and accept values that aren't predefined. For example, Qt's int QEvent::registerEventType()
allows you to create new valid enum values at runtime. The Haskell generator doesn't support this use case at the moment; toEnum
will error for such values. It would be nice for enums to be able to allow arbitrary integers to be used in their place, if they choose, say with a MyEnum_Custom Int
data constructor and possibly a typeclass to allow integer arguments.
As an alternate approach, making bindings create overloaded functions that take integers instead doesn't suffice, because an explicit int-to-enum-value conversion is still required (so it would need a TIntEnum
or something).