Created
April 1, 2015 11:59
-
-
Save shigemk2/19e7d35662b7cbbe5a87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data TrafficLight = Red | Yellow | Green | |
instance Eq TrafficLight where | |
Red == Red = True | |
Green == Green = True | |
Yellow == Yellow = True | |
_ == _ = False | |
instance Show TrafficLight where | |
show Red = "Red light" | |
show Yellow = "Yellow light" | |
show Green = "Green light" | |
main = do | |
print $ Red == Red | |
print $ Red == Yellow | |
print $ Red `elem` [Red, Yellow, Green] | |
print $ [Red, Yellow, Green] | |
-- True | |
-- False | |
-- True | |
-- [Red light,Yellow light,Green light] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment