Type Synonyms
Use keyword "type", not "data"
- Type synonyms don't actually make anything new, just making a synonym for an already existing type.
- Just use synonyms to convey more information to make our code more descriptive.
Synonyms for simple types
> type Name = String
> :paste
… myName1 :: Name
… myName1 = "Joe"
…
> myName1
"Joe"
Synonyms for complex types
Synonyms for complex types, such as Record,
type Person = { name :: String, age :: Int, address :: String }
p1 :: Person
p1 = {name: "Joe", address: "Fake city", age: 43}
when use 'data', when use 'type'?