| 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}
{ GHC.
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 do
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
fromEn
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 = Re