Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2010 20:30
Show Gist options
  • Save anonymous/741048 to your computer and use it in GitHub Desktop.
Save anonymous/741048 to your computer and use it in GitHub Desktop.
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