
On May 12, 2021, at 4:35 PM, chessai
wrote: Note that it is probably just missing some `error` calls in the right place.
Well, fromEnum for such instances is necessarily fragile, because: * The cardinality of the of the product set will often exceed the range of Int values, as e.g. with (Int, a) for any `a` with two or more elements. * The pair instance assumes that Bounded Enums have a minBound of zero, this is not true for e.g. Int8. The indices of the *inner*, less significant tuple terms have to be shifted to start at zero (possibly even using a larger integral result type than Int). innerToEnum x = toEnum (x :: t) - toEnum (minBound @t). Getting this right takes care, and it is IMHO likely to cause more issues that it would solve. Users who really want this can employ suitable newtype wrappers. -- Viktor.