Suppose I have this data type:
data TrafficLight = Red | Yellow | Green deriving (Eq)
How is it different from creating an instance of Eq
like so:
data TrafficLight = Red | Yellow | Green
instance Eq TrafficLight where
Red == Red = True
Green == Green = True
Yellow == Yellow = True
_ == _ = False
What am I missing here?
NOTE
This question is different from the assumed duplicate because I am looking for the contrast between the deriving
and instance
keyword. The assumed dupe does not mention the instance
keyword.