2 Jun
2018
2 Jun
'18
3:47 a.m.
On Jun 1, 2018, at 3:20 PM, Tom Ellis <tom-lists-haskell-cafe-2013@jaguarpaw.co.uk> 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.