diff options
Diffstat (limited to 'traffic.hs')
-rw-r--r-- | traffic.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/traffic.hs b/traffic.hs new file mode 100644 index 0000000..f409de3 --- /dev/null +++ b/traffic.hs @@ -0,0 +1,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 |