Explorar o código

corrected an error in the trafficlight example

Andrea Gus %!s(int64=9) %!d(string=hai) anos
pai
achega
c49b53768b
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  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"