RE: unexpected arithmetic sequence and deriving Enum behaviour

2006-07-03 Thread Simon Peyton-Jones
| one, and the program compiles. Interestingly, -ddump-deriv doesn't show | anything about deriving instances for Colour, yet, obviously something | gets derived. For me (ghc 6.4.2) it says: Derived instances InstInfo: {GHC.Show.Show Foo4.Colour} {

unexpected arithmetic sequence and deriving Enum behaviour

2006-06-30 Thread Laszlo Nemeth
Hi, Consider the following code fragment: data Colour = Red | Black | Blue deriving (Show, Bounded) instance Enum Colour where succ Red = Black succ Black = Blue succ Blue = error succ of maxBound fromEnum Red = 1 fromEnum Black = 2 fromEnum Blue = 3 toEnum 1 = Red

Re: unexpected arithmetic sequence and deriving Enum behaviour

2006-06-30 Thread Simon Marlow
Hi Laszlo, Laszlo Nemeth wrote: Consider the following code fragment: data Colour = Red | Black | Blue deriving (Show, Bounded) instance Enum Colour where succ Red = Black succ Black = Blue succ Blue = error succ of maxBound fromEnum Red = 1 fromEnum Black = 2

Re: unexpected arithmetic sequence and deriving Enum behaviour

2006-06-30 Thread Stefan Holdermans
Simon, Laszlo presented some code: Consider the following code fragment: data Colour = Red | Black | Blue deriving (Show, Bounded) instance Enum Colour where ... and then remarked: Notice that there is no deriving Enum (which would be an error according to the Report) You asked: Why