Enum and bounded instances for (,) and Either
Henning Thielemann
lemming at henning-thielemann.de
Wed May 12 17:59:40 UTC 2021
On Wed, 12 May 2021, Sandy Maguire wrote:
> Found myself puzzled the other day when I wanted an (Enum a, Enum b) =>
> Enum (a, b) instance, and was distraught that it didn't exist.
>
> The following is a reasonable implementation:
This is certainly an instance that fulfills some laws, but do we really
want it or is it more likely an accident if someone writes, say, succ
(a,b)?
We already allow "max (a,b) (c,d)", which can be pretty counterintuitive.
I think the Ord instance for pairs is currently mostly used for Set and
Map, but a separate class for this purpose would have been better.
More information about the Libraries
mailing list