[Haskell-cafe] Custom Enum instance with non-consecutive indices
Herbert Valerio Riedel
hvr at gnu.org
Sat Nov 17 16:27:42 CET 2012
Nicolas Trangez <nicolas at incubaid.com> writes:
> On Sat, 2012-11-17 at 16:52 +0200, Roman Cheplyaka wrote:
>> Hi Nicolas,
>> The simplest approach would be to use the standard (derived) Enum
>> instance that would be used for enumerations (like [Flag1..]), and
>> have your own functions to convert to/from magic constants.
> Sure, but that kind-of defeats the purpose... fromEnum/toEnum would then
> return some nonsensical integer value.
...then don't derive an 'Enum' instance for that :-)
what do you hope to gain from making your flags type an instance of the
More information about the Haskell-Cafe