Newtypes

newtypes are used to distinguish two types which have have the same type of value but different units/meanings.

For example:

  1. newtype Email = Email String
  2. m1 :: Map Email Integer
  3. m1 = empty
  4. --This is forces us to only pass a String with a contrutor Email.
  5. --So insert "abc" 123 m1 will fail