Skip to content

Instantly share code, notes, and snippets.

@chris-martin
Created February 22, 2017 21:40
Show Gist options
  • Save chris-martin/06abc096f6757d25c17ecaf3ef550485 to your computer and use it in GitHub Desktop.
Save chris-martin/06abc096f6757d25c17ecaf3ef550485 to your computer and use it in GitHub Desktop.
data Person = Person { firstName :: String, lastName :: String, age :: Int }
fullName :: Person -> String
fullName = firstName <> (const " ") <> lastName
summary :: Person -> String
summary = const "Name: " <> fullName <> const "; Age: " <> (show <$> age)
case class Person(firstName: String, lastName: String, age: Int) {
def fullName: String = firstName ++ " " ++ lastName
def summary: String = "Name: " ++ fullName ++ "; Age: " ++ age.toString
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment