summaryrefslogtreecommitdiff
path: root/traffic.hs
blob: f409de39ccaa368e1e18fc03732d5d10d996f6b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
data TrafficLight = Red | Yellow | Green

instance Eq TrafficLight where
    Red == Red = True
    Yellow == Yellow = True
    Green == Green = True
    _ == _ = False

instance Show TrafficLight where
    show Red = "Red light"
    show Yellow = "Yellow light"
    show Green = "Green light"

data Either a b = Left a | Right b