Skip to content

Instantly share code, notes, and snippets.

@friedbrice
Last active August 9, 2020 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save friedbrice/5bdc1a05ee881388c4fe0099ed61fddf to your computer and use it in GitHub Desktop.
Save friedbrice/5bdc1a05ee881388c4fe0099ed61fddf to your computer and use it in GitHub Desktop.
type Address = {
street: string
zipCode: string
}
type Contact = {
name: string
phoneNumber: string
email: string
}
type User = Address & Contact
const printUser = (user: User) => ...
data Address = Address { street :: String, zipCode :: String }
data Contact = Contact { name :: String, phoneNumber :: String, email :: String }
type User = (Address, Contact)
printUser :: User -> String
printUser (address, contact) =
let
Address { street = s, zipCode = z } = address
Contact { name = n, phoneNumber = p, email = e } = contact
in
n ++ ", " ++ p ++ ", " ++ e ++ "\n" ++ s ++ ", " ++ z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment