Hi Rudolf,
In this case you should be able to use generic equality:
importStdEnv
importData.GenEq
::Enum =A |B |C
instance ==Enum derive gEq
derivegEq Enum
If you want to handle certain cases non-generically you can use:
instance ==Enum
where
(==) A A =False
(==) s1s2=s1===s2
Kind regards,
Gijs Alberts
On 10/3/22 19:58, Rudolf Meijer via clean-list wrote:
I need to compare two values of an "enumeration type" for equality.
Say the type definition is :: Enum = A | B | C. The only way I have
found to overload == on this type is the following:
instance == Enum
where
(==) s1 s2 = case (s1, s2) of
(A, A) = True
(B, B) = True
(C, C) = True
otherwise = False
Although this works (I have checked), it does seem clumsy and will get
less workable when the enumeration type has quite a few values more.
Who has a better idea?
Thanks again in advance.
Rudolf Meijer
_______________________________________________
clean-list mailing list
[email protected]
https://mailman.science.ru.nl/mailman/listinfo/clean-list
_______________________________________________
clean-list mailing list
[email protected]
https://mailman.science.ru.nl/mailman/listinfo/clean-list