Browse Source

corrected an error in the trafficlight example

Andrea Gus 9 năm trước cách đây
mục cha
commit
c49b53768b
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      haskell/haskell2.hs

+ 5 - 1
haskell/haskell2.hs

@@ -109,8 +109,12 @@ treeValues4 t = treeFoldl (++) [] (treeMap (:[]) t)
 data TrafficLight = Red | Yellow | Green
 
 instance Eq TrafficLight where
-        Red == red = True
+        Red == Red = True
         Yellow == Yellow = True
         Green == Green = True
         _ == _ = False
 
+instance Show TrafficLight where
+        show Red = "The light is red"
+        show Yellow = "The light is yellow"
+        show Green = "The light is green"