Challenge 1: A TrafficLight Sum Type With a Cycling Function — Possible Solution ==================================================================== Main.hs: data TrafficLight = Red | Yellow | Green deriving (Show) next :: TrafficLight -> TrafficLight next Red = Green next Green = Yellow next Yellow = Red main :: IO () main = do print (next Red) print (next Green) print (next Yellow) Output: Green Yellow Red Explanation: TrafficLight is a sum type with three no-argument constructors -- Red, Yellow, and Green are each complete, distinct values of the type on their own, no additional data attached. next pattern-matches on each possible constructor directly, one equation per case, defining the exact Red -> Green -> Yellow -> Red cycle requested. deriving (Show) lets each value print as its own constructor name automatically, which is why print (next Red) shows "Green" rather than an error. WHY THIS WORKS AS AN ANSWER ------------------------------ This defines a genuine sum type with three no-argument alternatives, matching the chapter's own Shape-style data declaration shape, and implements the requested cycle using one pattern-matched equation per constructor.