소스 검색

corrected an error in the trafficlight example

Andrea Gus 9 년 전
부모
커밋
c49b53768b
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  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"