-- ADT flavor data Fruit = Apple | Banana | Cantaloupe -- deriving Enum through Generic or do by hand? -- versus -- Variant flavor type Fruit = Data.Variant.Variant ( apple ∷ Unit , banana ∷ Unit , cantaloupe ∷ Unit )
I know there various ergonomic issues either way, but what is preferred when consuming a library? Variant is easier to extend and isn’t that hard to use, but I feel like when it’s just
Unit values, it’s not as useful.
In my case I want the ‘labels’ of the variant to be a defined set of possible incoming and outgoing values for an FFI according to a W3 specification. The advantage of variant is that you can exactly match the expect
Strings casing with
Variant.inj "apple" unit or use normally-invalid leading characters like an integer, but again the
unit feels wrong, so ergonomics may want to see proxies like below, but adds a maintenance burden.
_apple ∷ Fruit _apple = Data.Variant.inj "apple" unit
What do y’all normally do in this case?