Open edsko opened 3 months ago
As an example, given
typedef enum
{
AS_X,
AS_Y,
AS_Z
} acme_sum;
we might want to generate
data AcmeSum = ASX | ASY | ASZ
Also enum
s can contain duplicate values:
enum foo { fail = 1, bad = 1, good = 0 };
This is the high-level counterpart to #15. This is probably relatively simple, turning the C enum into a Haskell ADT. We do need to think about error handling here though: C enums are just
int
s; what if a function returns something about of the declared range of the enum? This is uncommon; Wikipedia says(Emphasis not in original.) Thus, turning an enum into an ADT with a strictly limited range must be opt-in.
Moreover, not all enums correspond to ADTs at all; tracking "bitmap
enum
s" separately at https://github.com/well-typed/hs-bindgen/issues/65.