
1 Jun
2018
1 Jun
'18
3:47 p.m.
On Jun 1, 2018, at 3:20 PM, Tom Ellis
wrote: instance forall a b. (Bounded a, Bounded b, Enum a, Enum b) => Enum (E a b) where fromEnum = \case L a -> fromEnum a R b -> fromEnum (maxBound :: a) + fromEnum b + 1
This appears to assume that (fromEnum b) is never negative. (effectively that (minBound :: b) >= 0). Ignoring overflow issues, this should perhaps be: R b -> fromEnum (maxBound :: a) + (fromEnum b - fromEnum (minBound :: b)) + 1 This will of course overflow when ranges of a and/or b are large enough. -- Viktor.