Created
December 14, 2010 20:30
-
-
Save anonymous/741048 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
module Person where | |
data Condition = Bad | OK | Good | |
deriving (Show) | |
data Person = | |
Man {name :: String, age :: Int, prostateCondition :: Condition} | |
| Woman {name :: String, age :: Int, ovaryCondition :: Condition} | |
getGenderSpecificCondition ( Man _ _ cond) = cond | |
getGenderSpecificCondition (Woman _ _ cond) = cond | |
data Group = Group { members :: [Person] } | |
instance Show Group where | |
show group = unlines $ map show $ members group | |
instance Show Person where | |
show p = name p ++ "(" ++ (show $ age p) ++ ", " ++ (show $ getGenderSpecificCondition p) ++ ")" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment